Documentation ¶
Overview ¶
Package component contains code that is shared by all components (discovery, router, broker, networkserver, handler)
Index ¶
- func OnInitialize(fun initFunc)
- type Component
- func (c *Component) Announce() error
- func (c *Component) BuildJWT() (string, error)
- func (c *Component) Discover(serviceName, id string) (*pb_discovery.Announcement, error)
- func (c *Component) ExchangeAppKeyForToken(appID, key string) (string, error)
- func (c *Component) GetContext(token string) context.Context
- func (c *Component) GetStatus() Status
- func (c *Component) InitAuth() error
- func (c *Component) RegisterHandled(msg message)
- func (c *Component) RegisterHealthServer(srv *grpc.Server)
- func (c *Component) RegisterReceived(msg message)
- func (c *Component) ServerOptions() []grpc.ServerOption
- func (c *Component) SetStatus(s Status)
- func (c *Component) UpdateTokenKey() error
- func (c *Component) ValidateNetworkContext(ctx context.Context) (component *pb_discovery.Announcement, err error)
- func (c *Component) ValidateTTNAuthContext(ctx context.Context) (*claims.Claims, error)
- type Config
- type Interface
- type ManagementInterface
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OnInitialize ¶
func OnInitialize(fun initFunc)
OnInitialize registers a function that is called when any Component is initialized
Types ¶
type Component ¶
type Component struct { Config Config Pool *pool.Pool Identity *pb_discovery.Announcement Discovery discoveryclient.Client Monitor *monitorclient.MonitorClient Ctx ttnlog.Interface Context context.Context AccessToken string TokenKeyProvider tokenkey.Provider // contains filtered or unexported fields }
Component contains the common attributes for all TTN components
func (*Component) Discover ¶
func (c *Component) Discover(serviceName, id string) (*pb_discovery.Announcement, error)
Discover is used to discover another component
func (*Component) ExchangeAppKeyForToken ¶
ExchangeAppKeyForToken enables authentication with the App Access Key
func (*Component) GetContext ¶
GetContext returns a context for outgoing RPC request. If token is "", this function will generate a short lived token from the component
func (*Component) RegisterHandled ¶
func (c *Component) RegisterHandled(msg message)
RegisterHandled registers a handled message
func (*Component) RegisterHealthServer ¶
RegisterHealthServer registers the component's health status to the gRPC server
func (*Component) RegisterReceived ¶
func (c *Component) RegisterReceived(msg message)
RegisterReceived registers a received message
func (*Component) ServerOptions ¶
func (c *Component) ServerOptions() []grpc.ServerOption
func (*Component) UpdateTokenKey ¶
UpdateTokenKey updates the OAuth Bearer token key
func (*Component) ValidateNetworkContext ¶
func (c *Component) ValidateNetworkContext(ctx context.Context) (component *pb_discovery.Announcement, err error)
ValidateNetworkContext validates the context of a network request (router-broker, broker-handler, etc)
type Config ¶
Config is the configuration for this component
func ConfigFromViper ¶
func ConfigFromViper() Config
ConfigFromViper imports configuration from Viper