Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanDownlinks(items []*ttnpb.ApplicationDownlink) []*ttnpb.ApplicationDownlink

CleanDownlinks returns a copy of the given downlink items with only the fields that can be set by the application.

Types

type ContextualApplicationUp

type ContextualApplicationUp struct {
	context.Context
	*ttnpb.ApplicationUp
}

ContextualApplicationUp represents an ttnpb.ApplicationUp with its context.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option represents an option for the retry backend.

func WithBackoff

func WithBackoff(backoff []time.Duration) Option

WithBackoff configures the backoff interval for the resubscription attempts.

func WithJitter

func WithJitter(jitter float64) Option

WithJitter configures the jitter to be added to the resubscription attempts.

type OptionFunc

type OptionFunc func(*RetryServer)

OptionFunc is an option represented by a function.

type RetryServer

type RetryServer struct {
	// contains filtered or unexported fields
}

RetryServer is a Server that attempts to automatically re-subscribe to the upstream server by proxying Subscribe calls.

func (RetryServer) DownlinkQueueList

func (rs RetryServer) DownlinkQueueList(ctx context.Context, ids ttnpb.EndDeviceIdentifiers) ([]*ttnpb.ApplicationDownlink, error)

DownlinkQueueList implements Server using the upstream Server.

func (RetryServer) DownlinkQueuePush

func (rs RetryServer) DownlinkQueuePush(ctx context.Context, ids ttnpb.EndDeviceIdentifiers, downlinks []*ttnpb.ApplicationDownlink) error

DownlinkQueuePush implements Server using the upstream Server.

func (RetryServer) DownlinkQueueReplace

func (rs RetryServer) DownlinkQueueReplace(ctx context.Context, ids ttnpb.EndDeviceIdentifiers, downlinks []*ttnpb.ApplicationDownlink) error

DownlinkQueueReplace implements Server using the upstream Server.

func (RetryServer) FillContext

func (rs RetryServer) FillContext(ctx context.Context) context.Context

FillContext implements Server using the upstream Server.

func (RetryServer) GetBaseConfig

func (rs RetryServer) GetBaseConfig(ctx context.Context) config.ServiceBase

GetBaseConfig implements Server using the upstream Server.

func (RetryServer) SendUp

func (rs RetryServer) SendUp(ctx context.Context, up *ttnpb.ApplicationUp) error

SendUp implements Server using the upstream Server.

func (RetryServer) Subscribe

func (rs RetryServer) Subscribe(ctx context.Context, protocol string, ids ttnpb.ApplicationIdentifiers) (*Subscription, error)

Subscribe implements Server by proxying the Subscription object between the upstream server and the frontend.

type Server

type Server interface {
	// GetBaseConfig returns the component configuration.
	GetBaseConfig(ctx context.Context) config.ServiceBase
	// FillContext fills the given context.
	// This method should only be used for request contexts.
	FillContext(ctx context.Context) context.Context
	// SendUp sends upstream traffic to the Application Server.
	SendUp(ctx context.Context, up *ttnpb.ApplicationUp) error
	// Subscribe subscribes an application or integration by its identifiers to the Application Server, and returns a
	// Subscription for traffic and control.
	Subscribe(ctx context.Context, protocol string, ids ttnpb.ApplicationIdentifiers) (*Subscription, error)
	// DownlinkQueuePush pushes the given downlink messages to the end device's application downlink queue.
	DownlinkQueuePush(context.Context, ttnpb.EndDeviceIdentifiers, []*ttnpb.ApplicationDownlink) error
	// DownlinkQueueReplace replaces the end device's application downlink queue with the given downlink messages.
	DownlinkQueueReplace(context.Context, ttnpb.EndDeviceIdentifiers, []*ttnpb.ApplicationDownlink) error
	// DownlinkQueueList lists the application downlink queue of the given end device.
	DownlinkQueueList(context.Context, ttnpb.EndDeviceIdentifiers) ([]*ttnpb.ApplicationDownlink, error)
}

Server represents the Application Server to application frontends.

func NewRetryServer

func NewRetryServer(upstream Server, opts ...Option) Server

NewRetryServer creates a new RetryServer with the given upstream and options.

type Subscription

type Subscription struct {
	// contains filtered or unexported fields
}

Subscription is a subscription to an application or integration managed by a frontend.

func NewSubscription

func NewSubscription(ctx context.Context, protocol string, ids *ttnpb.ApplicationIdentifiers) *Subscription

NewSubscription instantiates a new application or integration subscription.

func (*Subscription) ApplicationIDs

func (s *Subscription) ApplicationIDs() *ttnpb.ApplicationIdentifiers

ApplicationIDs returns the application identifiers, if the subscription represents any specific.

func (*Subscription) Context

func (s *Subscription) Context() context.Context

Context returns the subscription context.

func (*Subscription) Disconnect

func (s *Subscription) Disconnect(err error)

Disconnect marks the subscription as disconnected and cancels the context.

func (*Subscription) Protocol

func (s *Subscription) Protocol() string

Protocol returns the protocol used for the subscription, i.e. grpc, mqtt or http.

func (*Subscription) SendUp

func (s *Subscription) SendUp(ctx context.Context, up *ttnpb.ApplicationUp) error

SendUp sends an upstream message. This method returns immediately, returning nil if the message is buffered, or with an error when the buffer is full.

func (*Subscription) Up

func (s *Subscription) Up() <-chan *ContextualApplicationUp

Up returns the upstream channel.

Directories

Path Synopsis
formatters
grpc
mock
mqtt Package mqtt implements the MQTT frontend.
mqtt/topics
packages
packages/loradms/v1
packages/loradms/v1/api
packages/loradms/v1/api/objects
packages/redis
pubsub Package pubsub implements the go-cloud PubSub frontend.
pubsub/provider
pubsub/provider/mock Package mock implements a mock PubSub provider using the mempubsub driver.
pubsub/provider/mqtt Package mqtt implements the MQTT provider using the mqtt driver.
pubsub/provider/nats Package nats implements the NATS provider using the natspubsub driver.
pubsub/redis
web Package web implements the webhooks integration.
web/redis