pubsub

package
v0.0.0-...-60b8695 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 22 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) (string, 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

type ProviderStatus int

ProviderStatus is the status of a PubSub provider.

type ProviderStatuses

type ProviderStatuses map[reflect.Type]ProviderStatus

ProviderStatuses maps a provider type to a provider status.

func ProviderStatusesFromMap

func ProviderStatusesFromMap(m map[string]string) (ProviderStatuses, error)

ProviderStatusesFromMap constructs the provider statuses from the provided map.

func (ProviderStatuses) Enabled

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.

Directories

Path Synopsis
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