Documentation ¶
Index ¶
- Variables
- func CleanDownlinks(items []*ttnpb.ApplicationDownlink) []*ttnpb.ApplicationDownlink
- type ContextualApplicationUp
- type Option
- type OptionFunc
- type RetryServer
- func (rs RetryServer) DownlinkQueueList(ctx context.Context, ids ttnpb.EndDeviceIdentifiers) ([]*ttnpb.ApplicationDownlink, error)
- func (rs RetryServer) DownlinkQueuePush(ctx context.Context, ids ttnpb.EndDeviceIdentifiers, ...) error
- func (rs RetryServer) DownlinkQueueReplace(ctx context.Context, ids ttnpb.EndDeviceIdentifiers, ...) error
- func (rs RetryServer) FillContext(ctx context.Context) context.Context
- func (rs RetryServer) GetBaseConfig(ctx context.Context) config.ServiceBase
- func (rs RetryServer) SendUp(ctx context.Context, up *ttnpb.ApplicationUp) error
- func (rs RetryServer) Subscribe(ctx context.Context, protocol string, ids ttnpb.ApplicationIdentifiers) (*Subscription, error)
- type Server
- type Subscription
- func (s *Subscription) ApplicationIDs() *ttnpb.ApplicationIdentifiers
- func (s *Subscription) Context() context.Context
- func (s *Subscription) Disconnect(err error)
- func (s *Subscription) Protocol() string
- func (s *Subscription) SendUp(ctx context.Context, up *ttnpb.ApplicationUp) error
- func (s *Subscription) Up() <-chan *ContextualApplicationUp
Constants ¶
This section is empty.
Variables ¶
var ( // DialTaskBackoffConfig derives the component.DialTaskBackoffConfig and dynamically determines the backoff duration // based on recent error codes. DialTaskBackoffConfig = &component.TaskBackoffConfig{ Jitter: component.DefaultTaskBackoffJitter, IntervalFunc: func(ctx context.Context, executionDuration time.Duration, invocation uint, err error) time.Duration { intervals := dialTaskBackoffIntervals switch { case errors.IsFailedPrecondition(err), errors.IsUnauthenticated(err), errors.IsPermissionDenied(err), errors.IsInvalidArgument(err), errors.IsAlreadyExists(err), errors.IsCanceled(err), errors.IsNotFound(err): intervals = dialTaskExtendedBackoffIntervals } switch { case executionDuration > component.DefaultTaskBackoffResetDuration: return intervals[0] case invocation >= uint(len(intervals)): return intervals[len(intervals)-1] default: return intervals[invocation-1] } }, } )
Functions ¶
func CleanDownlinks ¶
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 ¶
WithBackoff configures the backoff interval for the resubscription attempts.
func WithJitter ¶
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 ¶
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 |
---|---|
Package mqtt implements the MQTT frontend.
|
Package mqtt implements the MQTT frontend. |
Package pubsub implements the go-cloud pub/sub frontend.
|
Package pubsub implements the go-cloud pub/sub frontend. |
provider/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. |
provider/mqtt
Package mqtt implements the MQTT provider using the mqtt driver.
|
Package mqtt implements the MQTT provider using the mqtt driver. |
provider/nats
Package nats implements the NATS provider using the natspubsub driver.
|
Package nats implements the NATS provider using the natspubsub driver. |
Package web implements the webhooks integration.
|
Package web implements the webhooks integration. |