applicationserver

package
v3.24.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: Apache-2.0 Imports: 51 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 {
	ttnpb.UnimplementedAsServer
	ttnpb.UnimplementedNsAsServer

	*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 added in v3.11.0

GetConfiguration implements ttnpb.AsServer.

func (*ApplicationServer) GetEndDevice added in v3.17.2

func (as *ApplicationServer) GetEndDevice(ctx context.Context, ids *ttnpb.EndDeviceIdentifiers, paths []string) (*ttnpb.EndDevice, error)

GetEndDevice retrieves the end device associated with the provided identifiers from the end device registry.

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 added in v3.11.0

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 (as *ApplicationServer) RangeUplinks(ctx context.Context, ids *ttnpb.EndDeviceIdentifiers, paths []string, f func(ctx context.Context, up *ttnpb.ApplicationUplink) bool) error

RangeUplinks ranges the application uplinks and calls the callback function, until false is returned.

func (*ApplicationServer) RegisterHandlers

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

RegisterHandlers registers gRPC handlers.

func (*ApplicationServer) RegisterRoutes added in v3.17.2

func (as *ApplicationServer) RegisterRoutes(s *web.Server)

RegisterRoutes registers HTTP routes.

func (*ApplicationServer) RegisterServices

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

RegisterServices registers services provided by as at s.

func (*ApplicationServer) Roles

func (*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 ApplicationUplinkRegistry added in v3.12.2

type ApplicationUplinkRegistry interface {
	// Range ranges the uplink messagess and calls the callback function, until false is returned.
	Range(ctx context.Context, ids *ttnpb.EndDeviceIdentifiers, paths []string, f func(context.Context, *ttnpb.ApplicationUplink) bool) error
	// Push pushes the provided uplink message to the storage.
	Push(ctx context.Context, ids *ttnpb.EndDeviceIdentifiers, up *ttnpb.ApplicationUplink) error
	// Clear empties the uplink messages storage by the end device identifiers.
	Clear(ctx context.Context, ids *ttnpb.EndDeviceIdentifiers) error
}

ApplicationUplinkRegistry is a store for uplink messages.

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:"-"`
	UplinkStorage            UplinkStorageConfig            `name:"uplink-storage" description:"Application uplinks storage configuration"`
	Formatters               FormattersConfig               `name:"formatters" description:"Payload formatters configuration"`
	Distribution             DistributionConfig             `name:"distribution" description:"Distribution configuration"`
	EndDeviceFetcher         EndDeviceFetcherConfig         `name:"fetcher" description:"Deprecated - End Device fetcher configuration"`
	EndDeviceMetadataStorage EndDeviceMetadataStorageConfig `name:"end-device-metadata-storage" description:"End device metadata storage 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"`
	DeviceLastSeen           LastSeenConfig                 `name:"device-last-seen" description:"End Device last seen batch update configuration"`
}

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)
	// Range ranges over the end devices and calls the callback function, until false is returned.
	Range(ctx context.Context, paths []string, f func(context.Context, *ttnpb.EndDeviceIdentifiers, *ttnpb.EndDevice) bool) error
}

DeviceRegistry is a store for end devices.

type DistributionConfig added in v3.11.0

type DistributionConfig struct {
	Timeout time.Duration           `name:"timeout" description:"Wait timeout of an empty subscription set"`
	Local   LocalDistributorConfig  `name:"local" description:"Local distributor configuration"`
	Global  GlobalDistributorConfig `name:"global" description:"Global distributor configuration"`
}

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

type DistributorConfig added in v3.16.0

type DistributorConfig struct {
	SubscriptionQueueSize int  `name:"subscription-queue-size" description:"Number of uplinks to queue for each subscriber"`
	SubscriptionBlocks    bool `name:"subscription-blocks" description:"Controls if traffic should be dropped if the queue of a subscriber is full"`
}

DistributorConfig contains the configuration of a traffic distributor of the Application Server.

func (DistributorConfig) SubscriptionOptions added in v3.16.0

func (c DistributorConfig) SubscriptionOptions() []io.SubscriptionOption

SubscriptionOptions generates the subscription options based on the configuration.

type EndDeviceFetcherCacheConfig added in v3.10.0

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 added in v3.12.0

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"`
}

EndDeviceFetcherCircuitBreakerConfig represents the configuration for the circuit breaker of the end device fetcher.

type EndDeviceFetcherConfig added in v3.10.0

type EndDeviceFetcherConfig struct {
	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.

type EndDeviceLocationStorageCacheConfig added in v3.16.2

type EndDeviceLocationStorageCacheConfig struct {
	Cache              metadata.EndDeviceLocationCache `name:"-"`
	Enable             bool                            `name:"enable" description:"Enable caching of end device locations"`
	MinRefreshInterval time.Duration                   `name:"min-refresh-interval" description:"Minimum time interval between two asynchronous refreshes"`
	MaxRefreshInterval time.Duration                   `name:"max-refresh-interval" description:"Maximum time interval between two asynchronous refreshes"`
	TTL                time.Duration                   `name:"eviction-ttl" description:"Time to live of cached locations"`
}

EndDeviceLocationStorageCacheConfig represents the configuration of end device location registry caching.

type EndDeviceLocationStorageConfig added in v3.16.2

type EndDeviceLocationStorageConfig struct {
	Registry metadata.EndDeviceLocationRegistry  `name:"-"`
	Timeout  time.Duration                       `name:"timeout" description:"Timeout of the end device retrival operation"`
	Cache    EndDeviceLocationStorageCacheConfig `name:"cache"`
}

EndDeviceLocationStorageConfig represents the configuration of end device locations storage.

func (EndDeviceLocationStorageConfig) NewRegistry added in v3.16.2

NewRegistry returns a new end device location registry based on the configuration.

type EndDeviceMetadataStorageConfig added in v3.16.2

type EndDeviceMetadataStorageConfig struct {
	Location EndDeviceLocationStorageConfig `name:"location"`
}

EndDeviceMetadataStorageConfig represents the configuration of end device metadata operations.

type FormattersConfig added in v3.13.0

type FormattersConfig struct {
	MaxParameterLength int `name:"max-parameter-length" description:"Maximum allowed size for length of formatter parameters (payload formatter scripts)"`
}

FormattersConfig represents the configuration for payload formatters.

type GlobalDistributorConfig added in v3.16.0

type GlobalDistributorConfig struct {
	PubSub     distribution.PubSub `name:"-"`
	Individual DistributorConfig   `name:"individual" description:"Individual distributor configuration"`
}

GlobalDistributorConfig contains the configuration of the global traffic distributor of the Application Server.

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 LastSeenConfig added in v3.19.0

type LastSeenConfig struct {
	BatchSize     int           `name:"batch-size" description:"Maximum number of end device last seen timestamps to store for batch update"`
	FlushInterval time.Duration `name:"flush-interval" description:"Interval at which last seen timestamps are updated in batches"`
}

LastSeenConfig defines configuration for the device last seen map which stores timestamps for batch updates.

func (LastSeenConfig) NewLastSeen added in v3.19.0

NewLastSeen defines a new batch update map.

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 LocalDistributorConfig added in v3.16.0

type LocalDistributorConfig struct {
	Broadcast  DistributorConfig `name:"broadcast" description:"Broadcast distributor configuration"`
	Individual DistributorConfig `name:"individual" description:"Individual distributor configuration"`
}

LocalDistributorConfig contains the configuration of the local traffic distributor of the Application Server.

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 RegistryCleaner added in v3.15.2

type RegistryCleaner struct {
	DevRegistry    DeviceRegistry
	AppUpsRegistry ApplicationUplinkRegistry
	LocalSet       map[string]struct{}
}

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

func (*RegistryCleaner) CleanData added in v3.15.2

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

CleanData cleans registry device data.

func (*RegistryCleaner) DeleteDeviceData added in v3.15.2

func (cleaner *RegistryCleaner) DeleteDeviceData(ctx context.Context, devSet []string) error

DeleteDeviceData deletes registry application data of all devices in the device id list.

func (*RegistryCleaner) RangeToLocalSet added in v3.15.2

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

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

type UplinkStorageConfig added in v3.12.2

type UplinkStorageConfig struct {
	Registry ApplicationUplinkRegistry `name:"-"`
	Limit    int64                     `name:"limit" description:"Number of application uplinks to be stored"`
}

UplinkStorageConfig defines the configuration of the application uplinks storage used by integrations.

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"`
	UnhealthyAttemptsThreshold int                 `name:"unhealthy-attempts-threshold" description:"Number of failed webhook attempts before the webhook is disabled"`
	UnhealthyRetryInterval     time.Duration       `name:"unhealthy-retry-interval" description:"Time interval after which disabled webhooks may execute again"`
	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.
mqtt/topics
Package topics implements MQTT topic layouts.
Package topics implements MQTT topic layouts.
pubsub
Package pubsub implements the go-cloud pub/sub frontend.
Package pubsub implements the go-cloud pub/sub frontend.
pubsub/provider
Package provider implements pub/sub provider interfaces and registration.
Package provider implements pub/sub provider interfaces and registration.
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