Documentation
¶
Overview ¶
Package service represents the agent's core remoteconfig service
The `Service` type provides a communication layer for downstream clients to request configuration, as well as the ability to track clients for requesting complete update payloads from the remote config backend.
Index ¶
- func WithAPIKey(apiKey string) func(s *options)
- func WithAgentPollLoopDisabled() func(s *options)
- func WithClientCacheBypassLimit(limit int, cfgPath string) func(s *options)
- func WithClientTTL(interval time.Duration, cfgPath string) func(s *options)
- func WithConfigRootOverride(site string, override string) func(s *options)
- func WithDatabaseFileName(fileName string) func(s *options)
- func WithDatabasePath(path string) func(s *options)
- func WithDirectorRootOverride(site string, override string) func(s *options)
- func WithMaxBackoffInterval(interval time.Duration, cfgPath string) func(s *options)
- func WithOrgStatusRefreshInterval(interval time.Duration, cfgPath string) func(s *options)
- func WithPARJWT(jwt string) func(s *options)
- func WithRcKey(rcKey string) func(s *options)
- func WithRefreshInterval(interval time.Duration, cfgPath string) func(s *options)
- func WithTraceAgentEnv(env string) func(s *options)
- type AgentMetadata
- type ConfigFileMetaCustom
- type CoreAgentService
- func (s *CoreAgentService) ClientGetConfigs(_ context.Context, request *pbgo.ClientGetConfigsRequest) (*pbgo.ClientGetConfigsResponse, error)
- func (s *CoreAgentService) ConfigGetState() (*pbgo.GetStateConfigResponse, error)
- func (s *CoreAgentService) ConfigResetState() (*pbgo.ResetStateConfigResponse, error)
- func (s *CoreAgentService) Start()
- func (s *CoreAgentService) Stop() error
- func (s *CoreAgentService) UpdatePARJWT(jwt string)
- type HTTPClient
- type Option
- type RcTelemetryReporter
- type Service
- type WebSocketTestActor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithAPIKey ¶ added in v0.53.0
func WithAPIKey(apiKey string) func(s *options)
WithAPIKey sets the service API key
func WithAgentPollLoopDisabled ¶ added in v0.61.0
func WithAgentPollLoopDisabled() func(s *options)
WithAgentPollLoopDisabled disables the config poll loop
func WithClientCacheBypassLimit ¶ added in v0.53.0
WithClientCacheBypassLimit validates and sets the service client cache bypass limit
func WithClientTTL ¶ added in v0.53.0
WithClientTTL validates and sets the service client TTL
func WithConfigRootOverride ¶ added in v0.53.0
WithConfigRootOverride sets the service config root override
func WithDatabaseFileName ¶ added in v0.52.0
func WithDatabaseFileName(fileName string) func(s *options)
WithDatabaseFileName sets the service database file name
func WithDatabasePath ¶ added in v0.61.0
func WithDatabasePath(path string) func(s *options)
WithDatabasePath sets the service database path
func WithDirectorRootOverride ¶ added in v0.53.0
WithDirectorRootOverride sets the service director root override
func WithMaxBackoffInterval ¶ added in v0.53.0
WithMaxBackoffInterval validates sets the service maximum retry backoff time
func WithOrgStatusRefreshInterval ¶ added in v0.66.0
WithOrgStatusRefreshInterval validates and sets the service org status refresh interval
func WithPARJWT ¶ added in v0.62.0
func WithPARJWT(jwt string) func(s *options)
WithPARJWT sets the JWT for the private action runner
func WithRcKey ¶ added in v0.53.0
func WithRcKey(rcKey string) func(s *options)
WithRcKey sets the service remote configuration key
func WithRefreshInterval ¶ added in v0.53.0
WithRefreshInterval validates and sets the service refresh interval
func WithTraceAgentEnv ¶
func WithTraceAgentEnv(env string) func(s *options)
WithTraceAgentEnv sets the service trace-agent environment variable
Types ¶
type AgentMetadata ¶
type AgentMetadata struct {
Version string `json:"version"`
APIKeyHash string `json:"api-key-hash"`
CreationTime time.Time `json:"creation-time"`
URL string `json:"url"`
}
AgentMetadata is data stored in bolt DB to determine whether or not the agent has changed and the RC cache should be cleared
type ConfigFileMetaCustom ¶
type ConfigFileMetaCustom struct {
Predicates *pbgo.TracerPredicates `json:"tracer-predicates,omitempty"`
Expires int64 `json:"expires"`
}
ConfigFileMetaCustom is the custom metadata of a config
type CoreAgentService ¶ added in v0.59.0
type CoreAgentService struct {
Service
// contains filtered or unexported fields
}
CoreAgentService fetches Remote Configurations from the RC backend
func NewService ¶
func NewService(cfg model.Reader, rcType, baseRawURL, hostname string, tagsGetter func() []string, telemetryReporter RcTelemetryReporter, agentVersion string, opts ...Option) (*CoreAgentService, error)
NewService instantiates a new remote configuration management service
func (*CoreAgentService) ClientGetConfigs ¶ added in v0.59.0
func (s *CoreAgentService) ClientGetConfigs(_ context.Context, request *pbgo.ClientGetConfigsRequest) (*pbgo.ClientGetConfigsResponse, error)
ClientGetConfigs is the polling API called by tracers and agents to get the latest configurations
func (*CoreAgentService) ConfigGetState ¶ added in v0.59.0
func (s *CoreAgentService) ConfigGetState() (*pbgo.GetStateConfigResponse, error)
ConfigGetState returns the state of the configuration and the director repos in the local store
func (*CoreAgentService) ConfigResetState ¶ added in v0.70.0
func (s *CoreAgentService) ConfigResetState() (*pbgo.ResetStateConfigResponse, error)
ConfigResetState resets the remote configuration state, clearing the local store and reinitializing the uptane client
func (*CoreAgentService) Start ¶ added in v0.59.0
func (s *CoreAgentService) Start()
Start the remote configuration management service
func (*CoreAgentService) Stop ¶ added in v0.59.0
func (s *CoreAgentService) Stop() error
Stop stops the refresh loop and closes the on-disk DB cache
func (*CoreAgentService) UpdatePARJWT ¶ added in v0.62.0
func (s *CoreAgentService) UpdatePARJWT(jwt string)
UpdatePARJWT updates the stored JWT for Private Action Runners for authentication to the remote config backend.
type HTTPClient ¶ added in v0.59.0
type HTTPClient struct {
Service
// contains filtered or unexported fields
}
HTTPClient fetches Remote Configurations from an HTTP(s)-based backend
func NewHTTPClient ¶ added in v0.59.0
func NewHTTPClient(runPath, site, apiKey, agentVersion string) (*HTTPClient, error)
NewHTTPClient creates a new HTTPClient that can be used to fetch Remote Configurations from an HTTP(s)-based backend It uses a local db to cache the fetched configurations. Only one HTTPClient should be created per agent. An HTTPClient must be closed via HTTPClient.Close() before creating a new one.
func (*HTTPClient) Close ¶ added in v0.59.0
func (c *HTTPClient) Close() error
Close closes the HTTPClient and cleans up any resources. Close must be called before any other HTTPClients are instantiated via NewHTTPClient
func (*HTTPClient) GetCDNConfigUpdate ¶ added in v0.59.0
func (c *HTTPClient) GetCDNConfigUpdate( ctx context.Context, products []string, currentTargetsVersion, currentRootVersion uint64, ) (*state.Update, error)
GetCDNConfigUpdate returns any updated configs. If multiple requests have been made in a short amount of time, a cached response is returned. If RC has been disabled, an error is returned. If there is no update (the targets version is up-to-date) nil is returned for both the update and error.
type RcTelemetryReporter ¶
type RcTelemetryReporter interface {
// IncRateLimit is invoked when a cache bypass request is prevented due to rate limiting
IncRateLimit()
// IncTimeout is invoked when a cache bypass request is cancelled due to timeout or a previous cache bypass request is still pending
IncTimeout()
}
RcTelemetryReporter should be implemented by the agent to publish metrics on exceptional cache bypass request events
type Service ¶
Service defines the remote config management service responsible for fetching, storing and dispatching the configurations
type WebSocketTestActor ¶ added in v0.70.0
type WebSocketTestActor struct {
// contains filtered or unexported fields
}
WebSocketTestActor periodically calls rcwebsocket.RunWebSocketTest() in a background task.
func NewWebSocketTestActor ¶ added in v0.70.0
func NewWebSocketTestActor(client *api.HTTPClient) *WebSocketTestActor
NewWebSocketTestActor constructs a NewWebSocketTestActor that uses client to obtain a WebSocket connection to the RC backend.
func (*WebSocketTestActor) Start ¶ added in v0.70.0
func (s *WebSocketTestActor) Start()
Start runs this actor, spawning a background task to execute the test periodically.
This method is not concurrency safe, and panics if Start() has previously been called.
func (*WebSocketTestActor) Stop ¶ added in v0.70.0
func (s *WebSocketTestActor) Stop()
Stop signals the background task to stop asynchronously.
This method is not concurrency safe, and panics if Start() has not previously been called. It is safe to call Stop() repeatedly.