applicationserver

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: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationPackagesConfig

type ApplicationPackagesConfig struct {
	packages.Config `name:",squash"`
	Registry        packages.Registry `name:"-"`
}

ApplicationPackagesConfig contains application packages associations configuration.

func (ApplicationPackagesConfig) NewApplicationPackages

func (c ApplicationPackagesConfig) NewApplicationPackages(ctx context.Context, server io.Server) (packages.Server, error)

NewApplicationPackages returns a new applications packages frontend based on the configuration. If the registry is nil, it returns nil.

type ApplicationServer

type ApplicationServer struct {
	*component.Component
	// contains filtered or unexported fields
}

ApplicationServer implements the Application Server component.

The Application Server exposes the As, AppAs and AsEndDeviceRegistry services.

func New

func New(c *component.Component, conf *Config) (as *ApplicationServer, err error)

New returns new *ApplicationServer.

func (*ApplicationServer) Context

func (as *ApplicationServer) Context() context.Context

Context returns the context of the Application Server.

DeleteLink implements ttnpb.AsServer.

func (*ApplicationServer) DownlinkQueueList

DownlinkQueueList lists the application downlink queue of the given end device.

func (*ApplicationServer) DownlinkQueuePush

func (as *ApplicationServer) DownlinkQueuePush(ctx context.Context, ids ttnpb.EndDeviceIdentifiers, items []*ttnpb.ApplicationDownlink) error

DownlinkQueuePush pushes the given downlink messages to the end device's application downlink queue. This operation changes FRMPayload in the given items.

func (*ApplicationServer) DownlinkQueueReplace

func (as *ApplicationServer) DownlinkQueueReplace(ctx context.Context, ids ttnpb.EndDeviceIdentifiers, items []*ttnpb.ApplicationDownlink) error

DownlinkQueueReplace replaces the end device's application downlink queue with the given downlink messages. This operation changes FRMPayload in the given items.

func (*ApplicationServer) GetConfig

func (as *ApplicationServer) GetConfig(ctx context.Context) (*Config, error)

GetConfig returns the Application Server config based on the context.

func (*ApplicationServer) GetConfiguration

GetConfiguration implements ttnpb.AsServer.

GetLink implements ttnpb.AsServer.

func (*ApplicationServer) GetLinkStats

GetLinkStats implements ttnpb.AsServer.

func (*ApplicationServer) GetMQTTConfig

func (as *ApplicationServer) GetMQTTConfig(ctx context.Context) (*config.MQTT, error)

GetMQTTConfig returns the MQTT frontend configuration based on the context.

HandleUplink implements ttnpb.NsAsServer.

func (*ApplicationServer) Publish

func (as *ApplicationServer) Publish(ctx context.Context, up *ttnpb.ApplicationUp) error

Publish processes the given upstream message and then publishes it to the application frontends.

func (*ApplicationServer) RegisterHandlers

func (as *ApplicationServer) RegisterHandlers(s *runtime.ServeMux, conn *grpc.ClientConn)

RegisterHandlers registers gRPC handlers.

func (*ApplicationServer) RegisterServices

func (as *ApplicationServer) RegisterServices(s *grpc.Server)

RegisterServices registers services provided by as at s.

func (*ApplicationServer) Roles

func (as *ApplicationServer) Roles() []ttnpb.ClusterRole

Roles returns the roles that the Application Server fulfills.

SetLink implements ttnpb.AsServer.

func (*ApplicationServer) Subscribe

func (as *ApplicationServer) Subscribe(ctx context.Context, protocol string, ids *ttnpb.ApplicationIdentifiers, cluster bool) (*io.Subscription, error)

Subscribe subscribes an application or integration by its identifiers to the Application Server, and returns a Subscription for traffic and control. If the cluster parameter is true, the subscription receives all of the traffic of the application. Otherwise, only traffic that was processed locally is sent.

type Config

type Config struct {
	LinkMode         string                    `name:"link-mode" description:"Deprecated - mode to link applications to their Network Server (all, explicit)"`
	Devices          DeviceRegistry            `name:"-"`
	Links            LinkRegistry              `name:"-"`
	Distribution     DistributionConfig        `name:"distribution" description:"Distribution configuration"`
	EndDeviceFetcher EndDeviceFetcherConfig    `name:"fetcher" description:"End Device fetcher configuration"`
	MQTT             config.MQTT               `name:"mqtt" description:"MQTT configuration"`
	Webhooks         WebhooksConfig            `name:"webhooks" description:"Webhooks configuration"`
	PubSub           PubSubConfig              `name:"pubsub" description:"Pub/sub messaging configuration"`
	Packages         ApplicationPackagesConfig `name:"packages" description:"Application packages configuration"`
	Interop          InteropConfig             `name:"interop" description:"Interop client configuration"`
	DeviceKEKLabel   string                    `name:"device-kek-label" description:"Label of KEK used to encrypt device keys at rest"`
}

Config represents the ApplicationServer configuration.

type DeviceRegistry

type DeviceRegistry interface {
	// Get returns the end device by its identifiers.
	Get(ctx context.Context, ids ttnpb.EndDeviceIdentifiers, paths []string) (*ttnpb.EndDevice, error)
	// Set creates, updates or deletes the end device by its identifiers.
	Set(ctx context.Context, ids ttnpb.EndDeviceIdentifiers, paths []string, f func(*ttnpb.EndDevice) (*ttnpb.EndDevice, []string, error)) (*ttnpb.EndDevice, error)
}

DeviceRegistry is a store for end devices.

type DistributionConfig

type DistributionConfig struct {
	PubSub  distribution.PubSub `name:"-"`
	Timeout time.Duration       `name:"timeout" description:"Wait timeout of an empty subscription set"`
}

DistributionConfig contains the upstream traffic distribution configuration of the Application Server.

type EndDeviceFetcher

type EndDeviceFetcher interface {
	Get(ctx context.Context, ids ttnpb.EndDeviceIdentifiers, fieldMaskPaths ...string) (*ttnpb.EndDevice, error)
}

EndDeviceFetcher fetches end device protos.

func NewCachedEndDeviceFetcher

func NewCachedEndDeviceFetcher(fetcher EndDeviceFetcher, cache gcache.Cache) EndDeviceFetcher

NewCachedEndDeviceFetcher wraps an EndDeviceFetcher with a local cache.

func NewCircuitBreakerEndDeviceFetcher

func NewCircuitBreakerEndDeviceFetcher(fetcher EndDeviceFetcher, threshold uint64, timeout time.Duration) EndDeviceFetcher

NewCircuitBreakerEndDeviceFetcher wraps an end device fetcher with a circuit breaking mechanism. The circuit breaker opens when the number of failure attempts is higher than the threshold, and closes after the provided timeout.

func NewRegistryEndDeviceFetcher

func NewRegistryEndDeviceFetcher(c *component.Component) EndDeviceFetcher

NewRegistryEndDeviceFetcher returns a new endDeviceFetcher.

func NewSingleFlightEndDeviceFetcher

func NewSingleFlightEndDeviceFetcher(fetcher EndDeviceFetcher) EndDeviceFetcher

NewSingleFlightEndDeviceFetcher wraps an EndDeviceFetcher with a single flight mechanism.

func NewTimeoutEndDeviceFetcher

func NewTimeoutEndDeviceFetcher(fetcher EndDeviceFetcher, timeout time.Duration) EndDeviceFetcher

NewTimeoutEndDeviceFetcher wraps an EndDeviceFetcher and limits the lifetime of the context used to retrieve the end device.

type EndDeviceFetcherCacheConfig

type EndDeviceFetcherCacheConfig struct {
	Enable bool          `name:"enable" description:"Cache fetched end devices"`
	TTL    time.Duration `name:"ttl" description:"TTL for cached end devices"`
	Size   int           `name:"size" description:"Cache size"`
}

EndDeviceFetcherCacheConfig represents configuration for device information caching in Application Server.

type EndDeviceFetcherCircuitBreakerConfig

type EndDeviceFetcherCircuitBreakerConfig struct {
	Enable    bool          `name:"enable" description:"Enable circuit breaker behavior on burst errors"`
	Timeout   time.Duration `name:"timeout" description:"Timeout after which the circuit breaker closes"`
	Threshold int           `name:"threshold" description:"Number of failed fetching attempts after which the circuit breaker opens"`
}

type EndDeviceFetcherConfig

type EndDeviceFetcherConfig struct {
	Fetcher        EndDeviceFetcher                     `name:"-"`
	Timeout        time.Duration                        `name:"timeout" description:"Timeout of the end device retrival operation"`
	Cache          EndDeviceFetcherCacheConfig          `name:"cache" description:"Cache configuration options for the end device fetcher"`
	CircuitBreaker EndDeviceFetcherCircuitBreakerConfig `name:"circuit-breaker" description:"Circuit breaker options for the end device fetcher"`
}

EndDeviceFetcherConfig represents configuration for the end device fetcher in Application Server.

func (EndDeviceFetcherConfig) NewFetcher

NewFetcher creates an EndDeviceFetcher from config.

type InteropClient

type InteropClient interface {
	GetAppSKey(ctx context.Context, asID string, req *ttnpb.SessionKeyRequest) (*ttnpb.AppSKeyResponse, error)
}

InteropClient is a client, which Application Server can use for interoperability.

type InteropConfig

type InteropConfig struct {
	config.InteropClient `name:",squash"`
	ID                   string `name:"id" description:"AS-ID used for interoperability"`
}

InteropConfig represents interoperability client configuration.

type LinkRegistry

type LinkRegistry interface {
	// Get returns the link by the application identifiers.
	Get(ctx context.Context, ids ttnpb.ApplicationIdentifiers, paths []string) (*ttnpb.ApplicationLink, error)
	// Range ranges the links and calls the callback function, until false is returned.
	Range(ctx context.Context, paths []string, f func(context.Context, ttnpb.ApplicationIdentifiers, *ttnpb.ApplicationLink) bool) error
	// Set creates, updates or deletes the link by the application identifiers.
	Set(ctx context.Context, ids ttnpb.ApplicationIdentifiers, paths []string, f func(*ttnpb.ApplicationLink) (*ttnpb.ApplicationLink, []string, error)) (*ttnpb.ApplicationLink, error)
}

LinkRegistry is a store for application links.

type NoopEndDeviceFetcher

type NoopEndDeviceFetcher struct{}

NoopEndDeviceFetcher is a no-op.

func (*NoopEndDeviceFetcher) Get

func (f *NoopEndDeviceFetcher) Get(ctx context.Context, ids ttnpb.EndDeviceIdentifiers, fieldMaskPaths ...string) (*ttnpb.EndDevice, error)

Get implements the EndDeviceFetcher interface.

type PubSubConfig

type PubSubConfig struct {
	Registry pubsub.Registry `name:"-"`

	Providers map[string]string `name:"providers" description:"Controls the status of each provider (enabled, disabled, warning)"`
}

PubSubConfig contains go-cloud pub/sub configuration of the Application Server.

func (PubSubConfig) NewPubSub

func (c PubSubConfig) NewPubSub(comp *component.Component, server io.Server) (*pubsub.PubSub, error)

NewPubSub returns a new pubsub.PubSub based on the configuration. If the registry is nil, it returns nil.

type WebhooksConfig

type WebhooksConfig struct {
	Registry  web.WebhookRegistry `name:"-"`
	Target    string              `name:"target" description:"Target of the integration (direct)"`
	Timeout   time.Duration       `name:"timeout" description:"Wait timeout of the target to process the request"`
	QueueSize int                 `name:"queue-size" description:"Number of requests to queue"`
	Workers   int                 `name:"workers" description:"Number of workers to process requests"`
	Templates web.TemplatesConfig `name:"templates" description:"The store of the webhook templates"`
	Downlinks web.DownlinksConfig `name:"downlink" description:"The downlink queue operations configuration"`
}

WebhooksConfig defines the configuration of the webhooks integration.

func (WebhooksConfig) NewWebhooks

func (c WebhooksConfig) NewWebhooks(ctx context.Context, server io.Server) (web.Webhooks, error)

NewWebhooks returns a new web.Webhooks based on the configuration. If Target is empty, this method returns nil.

Directories

Path Synopsis
io
mqtt
Package mqtt implements the MQTT frontend.
Package mqtt implements the MQTT frontend.
pubsub
Package pubsub implements the go-cloud pub/sub frontend.
Package pubsub implements the go-cloud pub/sub frontend.
pubsub/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.
pubsub/provider/mqtt
Package mqtt implements the MQTT provider using the mqtt driver.
Package mqtt implements the MQTT provider using the mqtt driver.
pubsub/provider/nats
Package nats implements the NATS provider using the natspubsub driver.
Package nats implements the NATS provider using the natspubsub driver.
web
Package web implements the webhooks integration.
Package web implements the webhooks integration.

Jump to

Keyboard shortcuts

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