applicationserver

package
v3.10.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: Apache-2.0 Imports: 45 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.

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.

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.

func (*ApplicationServer) SendUp

SendUp processes the given uplink and then sends it to the application frontends.

SetLink implements ttnpb.AsServer.

func (*ApplicationServer) Subscribe

Subscribe subscribes an application or integration by its identifiers to the Application Server, and returns a io.Subscription for traffic and control.

type Config

type Config struct {
	LinkMode         string                    `name:"link-mode" description:"Mode to link applications to their Network Server (all, explicit)"`
	Devices          DeviceRegistry            `name:"-"`
	Links            LinkRegistry              `name:"-"`
	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.

func (Config) GetLinkMode

func (c Config) GetLinkMode() (LinkMode, error)

GetLinkMode returns the converted configuration's link mode to LinkMode.

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

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

EndDeviceFetcher fetches end device protos.

func NewCachedEndDeviceFetcher added in v3.10.0

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

NewCachedEndDeviceFetcher wraps an EndDeviceFetcher with a local cache.

func NewRegistryEndDeviceFetcher added in v3.10.0

func NewRegistryEndDeviceFetcher(c *component.Component) EndDeviceFetcher

NewRegistryEndDeviceFetcher returns a new endDeviceFetcher.

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

type EndDeviceFetcherConfig struct {
	Fetcher EndDeviceFetcher            `name:"-"`
	Cache   EndDeviceFetcherCacheConfig `name:"cache" description:"Cache configuration options for the end device fetcher"`
}

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

func (EndDeviceFetcherConfig) NewFetcher added in v3.10.0

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 LinkMode

type LinkMode int

LinkMode defines how applications are linked to their Network Server.

const (
	// LinkAll links all applications in the link registry to their Network Server automatically.
	LinkAll LinkMode = iota
	// LinkExplicit links applications on request.
	LinkExplicit
)

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

type NoopEndDeviceFetcher struct{}

NoopEndDeviceFetcher is a no-op.

func (*NoopEndDeviceFetcher) Get added in v3.10.0

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

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