pubsub

package
v3.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package pubsub implements the go-cloud pub/sub frontend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PubSubUID

func PubSubUID(appUID, id string) string

PubSubUID generates an unique ID based on an application unique ID and a pub/sub ID.

func SplitPubSubUID

func SplitPubSubUID(uid string) (appUID string, id string)

SplitPubSubUID parses a unique ID generated by `ID` and returns the application unique ID and the pub/sub ID.

Types

type Format

type Format struct {
	formatters.Formatter
	Name string
}

Format is a format to use for pub/sub integrations.

type ProviderStatus added in v3.11.0

type ProviderStatus int

ProviderStatus is the status of a PubSub provider.

type ProviderStatuses added in v3.11.0

type ProviderStatuses map[reflect.Type]ProviderStatus

ProviderStatuses maps a provider type to a provider status.

func ProviderStatusesFromMap added in v3.11.0

func ProviderStatusesFromMap(ctx context.Context, m map[string]string) (ProviderStatuses, error)

ProviderStatusesFromMap constructs the provider statuses from the provided map.

func (ProviderStatuses) Enabled added in v3.11.0

Enabled checks if the provided provider is enabled. Providers which are not specified in the map are considered to be enabled by default.

type PubSub

type PubSub struct {
	ttnpb.ApplicationPubSubRegistryServer

	*component.Component
	// contains filtered or unexported fields
}

PubSub is an pub/sub frontend that exposes ttnpb.ApplicationPubSubRegistryServer.

func New

func New(
	c *component.Component,
	server io.Server,
	registry Registry,
	providerStatuses ProviderStatuses,
) (*PubSub, error)

New creates a new pusub frontend.

func (*PubSub) Delete

Delete implements ttnpb.ApplicationPubSubRegistryServer.

func (*PubSub) Get

Get implements ttnpb.ApplicationPubSubRegistryServer.

func (*PubSub) GetFormats

func (ps *PubSub) GetFormats(ctx context.Context, _ *pbtypes.Empty) (*ttnpb.ApplicationPubSubFormats, error)

GetFormats implements ttnpb.ApplicationPubSubRegistryServer.

func (*PubSub) List

List implements ttnpb.ApplicationPubSubRegistryServer.

func (*PubSub) Set

Set implements ttnpb.ApplicationPubSubRegistryServer.

type Registry

type Registry interface {
	// Get returns the pub/sub integration by its identifiers.
	Get(ctx context.Context, ids *ttnpb.ApplicationPubSubIdentifiers, paths []string) (*ttnpb.ApplicationPubSub, error)
	// Range ranges over the pub/sub integrations and calls the callback function, until false is returned.
	Range(ctx context.Context, paths []string, f func(context.Context, *ttnpb.ApplicationIdentifiers, *ttnpb.ApplicationPubSub) bool) error
	// List returns all pub/sub integrations of the application.
	List(ctx context.Context, ids *ttnpb.ApplicationIdentifiers, paths []string) ([]*ttnpb.ApplicationPubSub, error)
	// Set creates, updates or deletes the pub/sub integration by its identifiers.
	Set(ctx context.Context, ids *ttnpb.ApplicationPubSubIdentifiers, paths []string, f func(*ttnpb.ApplicationPubSub) (*ttnpb.ApplicationPubSub, []string, error)) (*ttnpb.ApplicationPubSub, error)
}

Registry is a registry for pub/sub integrations.

type RegistryCleaner added in v3.15.2

type RegistryCleaner struct {
	PubSubRegistry Registry
	LocalSet       map[string]struct{}
}

RegistryCleaner is a service responsible for cleanup of the PubSub registry.

func (*RegistryCleaner) CleanData added in v3.15.2

func (cleaner *RegistryCleaner) CleanData(ctx context.Context, isSet map[string]struct{}) error

CleanData cleans registry application data.

func (*RegistryCleaner) DeleteApplicationData added in v3.15.2

func (cleaner *RegistryCleaner) DeleteApplicationData(ctx context.Context, applicationList []string) error

DeleteApplicationData deletes registry application data of all applications in the application list.

func (*RegistryCleaner) RangeToLocalSet added in v3.15.2

func (cleaner *RegistryCleaner) RangeToLocalSet(ctx context.Context) error

RangeToLocalSet returns a set of applications that have data in the registry.

Directories

Path Synopsis
Package provider implements pub/sub provider interfaces and registration.
Package provider implements pub/sub provider interfaces and registration.
mock
Package mock implements a mock pub/sub provider using the mempubsub driver.
Package mock implements a mock pub/sub provider using the mempubsub driver.
mqtt
Package mqtt implements the MQTT provider using the mqtt driver.
Package mqtt implements the MQTT provider using the mqtt driver.
nats
Package nats implements the NATS provider using the natspubsub driver.
Package nats implements the NATS provider using the natspubsub driver.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL