Documentation ¶
Overview ¶
Package commands implements the commands for the ttn-lw-stack binary.
Index ¶
- Variables
- func FetchIdentityServerApplications(ctx context.Context, client ttnpb.ApplicationRegistryClient, ...) ([]*ttnpb.Application, error)
- func FetchIdentityServerEndDevices(ctx context.Context, client ttnpb.EndDeviceRegistryClient, ...) ([]*ttnpb.EndDevice, error)
- func NewASDeviceRegistryCleaner(ctx context.Context, config *redis.Config) (*as.RegistryCleaner, error)
- func NewApplicationServerDeviceRegistryRedis(conf *Config) *redis.Client
- func NewClusterComponentConnection(ctx context.Context, config *Config, delay time.Duration, maxRetries int, ...) (*grpc.ClientConn, cluster.Cluster, error)
- func NewComponentDeviceRegistryRedis(conf *Config, name string) *redis.Client
- func NewIdentityServerTelemetryTaskRedis(conf *Config) *redis.Client
- func NewJSRegistryCleaner(ctx context.Context, config *ttnredis.Config) (*js.RegistryCleaner, error)
- func NewJoinServerDeviceRegistryRedis(conf *Config) *redis.Client
- func NewJoinServerSessionKeyRegistryRedis(conf *Config) *redis.Client
- func NewNSDeviceRegistryCleaner(ctx context.Context, config *redis.Config) (*ns.RegistryCleaner, error)
- func NewNetworkServerApplicationUplinkQueueRedis(conf *Config) *redis.Client
- func NewNetworkServerDeviceRegistryRedis(conf *Config) *redis.Client
- func NewNetworkServerDownlinkTaskRedis(conf *Config) *redis.Client
- func NewPackagesCleaner(ctx context.Context, config *redis.Config) (*packages.RegistryCleaner, error)
- func NewPubSubCleaner(ctx context.Context, config *redis.Config) (*pubsub.RegistryCleaner, error)
- func NewRateLimitingRedis(conf *Config) *redis.Client
- func NewWebhookCleaner(ctx context.Context, config *redis.Config) (*web.RegistryCleaner, error)
- type Config
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{ ServiceBase: shared.DefaultServiceBase, IS: shared_identityserver.DefaultIdentityServerConfig, GS: shared_gatewayserver.DefaultGatewayServerConfig, NS: shared_networkserver.DefaultNetworkServerConfig, AS: shared_applicationserver.DefaultApplicationServerConfig, JS: shared_joinserver.DefaultJoinServerConfig, Console: shared_console.DefaultConsoleConfig, GCS: shared_gatewayconfigurationserver.DefaultGatewayConfigurationServerConfig, DTC: shared_devicetemplateconverter.DefaultDeviceTemplateConverterConfig, QRG: shared_qrcodegenerator.DefaultQRCodeGeneratorConfig, PBA: shared_packetbrokeragent.DefaultPacketBrokerAgentConfig, DR: shared_devicerepository.DefaultDeviceRepositoryConfig, DCS: shared_deviceclaimingserver.DefaultDeviceClaimingServerConfig, OutputFormat: "json", }
DefaultConfig contains the default config for the ttn-lw-stack binary.
var ( // Root command is the entrypoint of the program. Root = &cobra.Command{ Use: name, SilenceErrors: true, SilenceUsage: true, Short: "The Things Stack for LoRaWAN", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { if cmd.Name() == "__complete" { return nil } err := mgr.ReadInConfig() if err != nil { return err } if err = mgr.Unmarshal(config); err != nil { return err } experimental.EnableFeatures(config.Experimental.Features...) if err := shared.InitializeFallbacks(&config.ServiceBase); err != nil { return err } logger, err = shared.InitializeLogger(&config.Log) if err != nil { return err } logger.Use(logobservability.New()) if config.Sentry.DSN != "" { opts := sentry.ClientOptions{ Dsn: config.Sentry.DSN, Release: pkgversion.String(), Environment: config.Sentry.Environment, } if hostname, err := os.Hostname(); err == nil { opts.ServerName = hostname } err = sentry.Init(opts) if err != nil { return err } logger.Use(logsentry.New()) } if _, err := maxprocs.Set(); err != nil { logger.WithError(err).Info("Failed to set GOMAXPROCS") } if _, err := memlimit.SetGoMemLimit(0.9); err != nil { logger.WithError(err).Info("Failed to set GOMEMLIMIT") } ctx = log.NewContext(ctx, logger) versionUpdate = make(chan *pkgversion.Update) if config.SkipVersionCheck { close(versionUpdate) } else { go func(ctx context.Context) { defer close(versionUpdate) update, err := pkgversion.CheckUpdate(ctx) if err != nil { log.FromContext(ctx).WithError(err).Warn("Failed to check version update") } else if update != nil { versionUpdate <- update } else { log.FromContext(ctx).Debug("No new version available") } }(ctx) } telemetryConfigFallback(ctx, config) return nil }, PersistentPostRunE: func(cmd *cobra.Command, args []string) error { if cmd.Name() == "__complete" { return nil } select { case <-ctx.Done(): case <-time.After(versionCheckTimeout): logger.Warn("Version check timed out") case versionUpdate, ok := <-versionUpdate: if ok { pkgversion.LogUpdate(ctx, versionUpdate) } } return nil }, } )
Functions ¶
func FetchIdentityServerApplications ¶ added in v3.15.2
func FetchIdentityServerApplications(ctx context.Context, client ttnpb.ApplicationRegistryClient, clusterAuth grpc.CallOption, paginationDelay time.Duration) ([]*ttnpb.Application, error)
FetchIdentityServerApplications returns the list of all non-expired applications in the Identity Server.
func FetchIdentityServerEndDevices ¶ added in v3.15.2
func FetchIdentityServerEndDevices(ctx context.Context, client ttnpb.EndDeviceRegistryClient, clusterAuth grpc.CallOption, paginationDelay time.Duration) ([]*ttnpb.EndDevice, error)
FetchIdentityServerEndDevices returns the list of all devices in the Identity Server.
func NewASDeviceRegistryCleaner ¶ added in v3.15.2
func NewASDeviceRegistryCleaner(ctx context.Context, config *redis.Config) (*as.RegistryCleaner, error)
NewASDeviceRegistryCleaner returns a new instance of device RegistryCleaner with a local set of devices.
func NewApplicationServerDeviceRegistryRedis ¶ added in v3.16.0
NewApplicationServerDeviceRegistryRedis instantiates a new redis client with the Application Server Device Registry namespace.
func NewClusterComponentConnection ¶ added in v3.15.2
func NewClusterComponentConnection(ctx context.Context, config *Config, delay time.Duration, maxRetries int, role ttnpb.ClusterRole, ) (*grpc.ClientConn, cluster.Cluster, error)
NewClusterComponentConnection connects returns a new cluster instance and a connection to a specified peer. The connection to a cluster peer is retried specified number of times before returning an error in case of connection not being ready.
func NewComponentDeviceRegistryRedis ¶ added in v3.9.3
NewComponentDeviceRegistryRedis instantiates a new redis client with the Component Device Registry namespace.
func NewIdentityServerTelemetryTaskRedis ¶ added in v3.25.1
NewIdentityServerTelemetryTaskRedis instantiates a new redis client with the Identity Server Telemetry Task namespace.
func NewJSRegistryCleaner ¶ added in v3.16.0
func NewJSRegistryCleaner(ctx context.Context, config *ttnredis.Config) (*js.RegistryCleaner, error)
NewJSRegistryCleaner returns a new instance of Join Server RegistryCleaner with a local set of devices and applications.
func NewJoinServerDeviceRegistryRedis ¶ added in v3.18.0
NewJoinServerDeviceRegistryRedis instantiates a new redis client with the Join Server Device Registry namespace.
func NewJoinServerSessionKeyRegistryRedis ¶ added in v3.18.0
NewJoinServerSessionKeyRegistryRedis instantiates a new redis client with the Join Server Session Key Registry namespace.
func NewNSDeviceRegistryCleaner ¶ added in v3.16.0
func NewNSDeviceRegistryCleaner(ctx context.Context, config *redis.Config) (*ns.RegistryCleaner, error)
NewNSDeviceRegistryCleaner returns a new instance of Network Server RegistryCleaner with a local set of devices.
func NewNetworkServerApplicationUplinkQueueRedis ¶ added in v3.9.3
NewNetworkServerApplicationUplinkQueueRedis instantiates a new redis client with the Network Server Application Uplink Queue namespace.
func NewNetworkServerDeviceRegistryRedis ¶ added in v3.9.3
NewNetworkServerDeviceRegistryRedis instantiates a new redis client with the Network Server Device Registry namespace.
func NewNetworkServerDownlinkTaskRedis ¶ added in v3.9.3
NewNetworkServerDownlinkTaskRedis instantiates a new redis client with the Network Server Downlink Task namespace.
func NewPackagesCleaner ¶ added in v3.15.2
func NewPackagesCleaner(ctx context.Context, config *redis.Config) (*packages.RegistryCleaner, error)
NewPackagesCleaner returns a new instance of packages RegistryCleaner with a local set of applications and devices.
func NewPubSubCleaner ¶ added in v3.15.2
NewPubSubCleaner returns a new instance of pubsub RegistryCleaner with a local set of applications.
func NewRateLimitingRedis ¶ added in v3.29.1
NewRateLimitingRedis instantiates a new redis client with the Rate Limiting namespace.
func NewWebhookCleaner ¶ added in v3.15.2
NewWebhookCleaner returns a new instance of webhook RegistryCleaner with a local set of applications.
Types ¶
type Config ¶
type Config struct { conf.ServiceBase `name:",squash"` IS identityserver.Config `name:"is"` GS gatewayserver.Config `name:"gs"` NS networkserver.Config `name:"ns"` AS applicationserver.Config `name:"as"` JS joinserver.Config `name:"js"` Console console.Config `name:"console"` GCS gatewayconfigurationserver.Config `name:"gcs"` DTC devicetemplateconverter.Config `name:"dtc"` QRG qrcodegenerator.Config `name:"qrg"` PBA packetbrokeragent.Config `name:"pba"` DR devicerepository.Config `name:"dr"` DCS deviceclaimingserver.Config `name:"dcs"` OutputFormat string `name:"output-format" yaml:"output-format" description:"Output format"` }
Config for the ttn-lw-stack binary.