component

package
v3.24.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Overview

Package component contains the methods and structures common to all components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	GRPC *rpcserver.Server
	// contains filtered or unexported fields
}

Component is a base component for The Things Network cluster

func MustNew

func MustNew(logger log.Stack, config *Config, opts ...Option) *Component

MustNew calls New and returns a new component or panics on an error. In most cases, you should just use New.

func New

func New(logger log.Stack, config *Config, opts ...Option) (c *Component, err error)

New returns a new component.

func (*Component) AddContextFiller

func (c *Component) AddContextFiller(f fillcontext.Filler)

AddContextFiller adds the specified filler.

func (*Component) AllowInsecureForCredentials

func (c *Component) AllowInsecureForCredentials() bool

AllowInsecureForCredentials returns `true` if the component was configured to allow transmission of credentials over insecure transports.

func (*Component) ClaimIDs

func (c *Component) ClaimIDs(ctx context.Context, ids cluster.EntityIdentifiers) error

ClaimIDs claims the identifiers in the cluster. See package ../cluster for more information.

func (*Component) Close

func (c *Component) Close()

Close closes the server.

func (*Component) ClusterAuthStreamHook

func (c *Component) ClusterAuthStreamHook() hooks.StreamHandlerMiddleware

ClusterAuthStreamHook ensuring the caller of an RPC is part of the cluster. If a call can't be identified as coming from the cluster, it will be discarded.

func (*Component) ClusterAuthUnaryHook

func (c *Component) ClusterAuthUnaryHook() hooks.UnaryHandlerMiddleware

ClusterAuthUnaryHook ensuring the caller of an RPC is part of the cluster. If a call can't be identified as coming from the cluster, it will be discarded.

func (*Component) ClusterTLS

func (c *Component) ClusterTLS() bool

ClusterTLS returns whether the cluster uses TLS for cluster connections.

func (*Component) ComponentKEKLabeler added in v3.24.0

func (c *Component) ComponentKEKLabeler() crypto.ComponentKEKLabeler

ComponentKEKLabeler returns the component's ComponentKEKLabeler

func (*Component) Context

func (c *Component) Context() context.Context

Context returns the context of the component.

func (*Component) FillContext

func (c *Component) FillContext(ctx context.Context) context.Context

FillContext fills the context. This method should only be used for request contexts.

func (*Component) FrequencyPlansStore added in v3.17.0

func (c *Component) FrequencyPlansStore(ctx context.Context) (*frequencyplans.Store, error)

FrequencyPlansStore returns the component's frequencyPlans Store

func (*Component) FromRequestContext added in v3.10.1

func (c *Component) FromRequestContext(ctx context.Context) context.Context

FromRequestContext returns a derived context from the component context with key values from the request context. This can be used to decouple the lifetime from the request context while keeping security information.

func (*Component) GetBaseConfig

func (c *Component) GetBaseConfig(ctx context.Context) config.ServiceBase

GetBaseConfig gets the base config of the component.

func (*Component) GetPeer

GetPeer returns a cluster peer with the given role and the given tags. See package ../cluster for more information.

func (*Component) GetPeerConn

GetPeerConn returns a gRPC client connection to the cluster peer. See package ../cluster for more information.

func (*Component) GetPeers

func (c *Component) GetPeers(ctx context.Context, role ttnpb.ClusterRole) ([]cluster.Peer, error)

GetPeers returns cluster peers with the given role and the given tags. See package ../cluster for more information.

func (*Component) GetTLSClientConfig

func (c *Component) GetTLSClientConfig(ctx context.Context, opts ...tlsconfig.Option) (*tls.Config, error)

GetTLSClientConfig gets the component's client TLS config and applies the given options.

func (*Component) GetTLSServerConfig

func (c *Component) GetTLSServerConfig(ctx context.Context, opts ...tlsconfig.Option) (*tls.Config, error)

GetTLSServerConfig gets the component's server TLS config and applies the given options.

func (*Component) HTTPClient added in v3.12.0

func (c *Component) HTTPClient(ctx context.Context, opts ...httpclient.Option) (*http.Client, error)

HTTPClient returns a new *http.Client with a default timeout and a configured transport.

func (*Component) HealthChecker added in v3.24.0

func (c *Component) HealthChecker() healthcheck.HealthChecker

HealthChecker returns the component's health checker.

func (*Component) KeyService added in v3.24.0

func (c *Component) KeyService() crypto.KeyService

KeyService returns the component's KeyService.

func (*Component) ListenTCP

func (c *Component) ListenTCP(address string) (Listener, error)

ListenTCP listens on a TCP address and allows for TCP and TLS on the same port.

func (*Component) ListenUDP

func (c *Component) ListenUDP(address string) (*net.UDPConn, error)

ListenUDP starts a listener on a UDP address.

func (*Component) LogDebug

func (c *Component) LogDebug() bool

LogDebug returns whether the component should log debug messages.

func (*Component) Logger

func (c *Component) Logger() log.Stack

Logger returns the logger of the component.

func (*Component) LoopbackConn

func (c *Component) LoopbackConn() *grpc.ClientConn

LoopbackConn returns the loopback gRPC connection to the component. This conn must *not* be closed.

func (*Component) RateLimiter added in v3.12.0

func (c *Component) RateLimiter() ratelimit.Interface

func (*Component) RegisterGRPC

func (c *Component) RegisterGRPC(s rpcserver.Registerer)

RegisterGRPC registers a gRPC subsystem to the component.

func (*Component) RegisterInterop

func (c *Component) RegisterInterop(s interop.Registerer)

RegisterInterop registers an interop subsystem to the component.

func (*Component) RegisterTask

func (c *Component) RegisterTask(conf *task.Config)

RegisterTask registers a task, optionally with restart policy and backoff, to be started after the component started.

func (*Component) RegisterWeb

func (c *Component) RegisterWeb(s web.Registerer)

RegisterWeb registers a web subsystem to the component.

func (*Component) Run

func (c *Component) Run() error

Run starts the component, and returns when a stop signal has been received by the process.

func (*Component) ServeHTTP

func (c *Component) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves an HTTP request. If the Content-Type is application/grpc, the request is routed to gRPC. Otherwise, the request is routed to the default web server.

func (*Component) Start

func (c *Component) Start() (err error)

Start starts the component.

func (*Component) StartTask

func (c *Component) StartTask(conf *task.Config)

StartTask implements the TaskStarter interface.

func (*Component) UnclaimIDs

func (c *Component) UnclaimIDs(ctx context.Context, ids cluster.EntityIdentifiers) error

UnclaimIDs unclaims the identifiers in the cluster. See package ../cluster for more information.

func (*Component) WithClusterAuth

func (c *Component) WithClusterAuth() grpc.CallOption

WithClusterAuth that can be used to identify a component within a cluster.

type Config

type Config struct {
	config.ServiceBase `name:",squash" yaml:",inline"`
}

Config is the type of configuration for Components

type ConfigurationServer

type ConfigurationServer struct {
	ttnpb.UnimplementedConfigurationServer
	// contains filtered or unexported fields
}

ConfigurationServer implements the Configuration RPC service.

func NewConfigurationServer

func NewConfigurationServer(c *Component) *ConfigurationServer

NewConfigurationServer returns a new ConfigurationServer on top of the given component.

func (*ConfigurationServer) GetPhyVersions added in v3.15.0

GetPhyVersions implements the Configuration service's GetPhyVersions RPC.

func (*ConfigurationServer) ListBands added in v3.21.2

ListBands implements the Configuration service's ListBands RPC.

func (*ConfigurationServer) ListFrequencyPlans

ListFrequencyPlans implements the Configuration service's ListFrequencyPlans RPC.

func (*ConfigurationServer) RegisterHandlers

func (c *ConfigurationServer) RegisterHandlers(s *runtime.ServeMux, conn *grpc.ClientConn)

RegisterHandlers registers the Configuration service handler.

func (*ConfigurationServer) RegisterServices

func (c *ConfigurationServer) RegisterServices(s *grpc.Server)

RegisterServices registers the Configuration service.

func (*ConfigurationServer) Roles

Roles implements the rpcserver.Registerer interface. It just returns nil.

type Endpoint

type Endpoint interface {
	Address() string
	Protocol() string
	Listen(Listener) (net.Listener, error)
}

Endpoint represents an endpoint that can be listened on.

func NewTCPEndpoint

func NewTCPEndpoint(address, protocol string) Endpoint

NewTCPEndpoint returns a new TCP endpoint.

func NewTLSEndpoint

func NewTLSEndpoint(address, protocol string, configOpts ...tlsconfig.Option) Endpoint

NewTLSEndpoint returns a new TLS endpoint.

type Listener

type Listener interface {
	TLS(opts ...tlsconfig.Option) (net.Listener, error)
	TCP() (net.Listener, error)
	Addr() net.Addr
	Close() error
}

Listener that accepts multiple protocols on the same port

type Option

type Option func(*Component)

Option allows extending the component when it is instantiated with New.

func WithBaseConfigGetter

func WithBaseConfigGetter(f func(ctx context.Context) config.ServiceBase) Option

WithBaseConfigGetter returns an option that overrides the component's function for getting the base config. This allows overriding the configuration with information in the context.

func WithClusterNew

func WithClusterNew(f func(ctx context.Context, config *cluster.Config, options ...cluster.Option) (cluster.Cluster, error)) Option

WithClusterNew returns an option that overrides the component's function for setting up the cluster. This allows extending the cluster configuration with custom logic based on information in the context.

func WithGRPCLogger added in v3.12.0

func WithGRPCLogger(l log.Interface) Option

WithGRPCLogger returns an option that overrides the component's gRPC logger.

func WithTaskStarter added in v3.9.1

func WithTaskStarter(s task.Starter) Option

WithTaskStarter returns an option that overrides the component's TaskStarter for starting tasks.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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