server

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AgentCleanupInterval is the default agent cleanup interval.
	AgentCleanupInterval = time.Minute
	// AgentCleanupTTL is the default agent cleanup time to live.
	AgentCleanupTTL = 15 * time.Minute
	// AgentHeartbeatInterval is the default interval for the heartbeat sent to the agent to keep the websocket live.
	AgentHeartbeatInterval = 30 * time.Second
)
View Source
const HeaderSessionID = "X-BindPlane-Session-ID"

HeaderSessionID is the name of the HTTP header where a BindPlane Session ID can be found. This will be used by Relayer to match up the request with an eventual response via OTLP HTTP POST.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentUpdates

type AgentUpdates struct {
	// Labels changes are only supported by OpAMP
	Labels *model.Labels

	// Configuration changes are only supported by OpAMP
	Configuration *model.Configuration

	// Version instructs the agent to install a specific version
	Version string
}

AgentUpdates contains fields that can be modified on an Agent and should be sent to the agent. The model.Agent should not be updated directly and will be updated when the agent reports its new status after the update is complete.

func (*AgentUpdates) Empty

func (u *AgentUpdates) Empty() bool

Empty returns true if the updates are empty because no changes need to be made to the agent

type BindPlane

type BindPlane interface {
	// Store TODO(doc)
	Store() store.Store
	// Manager TODO(doc)
	Manager() Manager
	// Relayer enables Live messages to flow from Agents to GraphQL subscriptions
	Relayers() *Relayers
	// Versions TODO(doc)
	Versions() agent.Versions
	// Config TODO(doc)
	Config() *common.Server
	// Logger TODO(doc)
	Logger() *zap.Logger
}

BindPlane TODO(doc)

func NewBindPlane

func NewBindPlane(config *common.Server, logger *zap.Logger, s store.Store, versions agent.Versions) (BindPlane, error)

NewBindPlane TODO(doc)

type Manager

type Manager interface {
	// Start starts the manager and allows it to begin processing configuration changes
	Start(ctx context.Context)
	// EnableProtocol adds the protocol to the manager
	EnableProtocol(Protocol)
	// Agent returns the agent with the specified agentID.
	Agent(ctx context.Context, agentID string) (*model.Agent, error)
	// UpsertAgent adds a new Agent to the Store or updates an existing one
	UpsertAgent(ctx context.Context, agentID string, updater store.AgentUpdater) (*model.Agent, error)
	// AgentUpdates returns the updates that should be applied to an agent based on the current bindplane configuration
	AgentUpdates(ctx context.Context, agent *model.Agent) (*AgentUpdates, error)
	// VerifySecretKey checks to see if the specified secretKey matches configured secretKey
	VerifySecretKey(ctx context.Context, secretKey string) bool
	// ResourceStore provides access to the store to render configurations
	ResourceStore() model.ResourceStore
	// BindPlaneConfiguration provides access to the config to render configurations
	BindPlaneConfiguration() model.BindPlaneConfiguration
	// RequestReport sends report configuration to the specified agent
	RequestReport(ctx context.Context, agentID string, configuration report.Configuration) error
	// AgentVersion returns information about a version of an agent
	AgentVersion(ctx context.Context, version string) (*model.AgentVersion, error)
}

Manager manages agent connects and communications with them

func NewManager

func NewManager(config *common.Server, store store.Store, versions agent.Versions, logger *zap.Logger) (Manager, error)

NewManager returns a new implementation of the Manager interface

type Protocol

type Protocol interface {
	// Name is the name for the protocol use mostly for logging
	Name() string

	// Connected returns true if the specified agent ID is connected
	Connected(agentID string) bool

	// ConnectedAgents should return a slice of the currently connected agent IDs
	ConnectedAgentIDs(context.Context) ([]string, error)

	// Disconnect closes the any connection to the specified agent ID
	Disconnect(agentID string) bool

	// UpdateAgent should send a message to the specified agent to apply the updates
	UpdateAgent(context.Context, *model.Agent, *AgentUpdates) error

	// SendHeartbeat sends a heartbeat to the agent to keep the websocket open
	SendHeartbeat(agentID string) error

	// RequestReport sends report configuration to the specified agent
	RequestReport(ctx context.Context, agentID string, configuration report.Configuration) error
}

Protocol represents a communication protocol for managing agents

type Relayer added in v1.1.0

type Relayer[T any] struct {
	// contains filtered or unexported fields
}

Relayer forwards results to consumers awaiting the results. It is intentionally generic and is used to support cases where the request for results is decoupled from the response with the results.

func (*Relayer[T]) AwaitResult added in v1.1.0

func (r *Relayer[T]) AwaitResult() (id string, result <-chan T, cancelFunc func())

AwaitResult will create a new ID and channel where results will be received. It also returns a cancelFunc that must be called to cleanup the channel.

func (*Relayer[T]) SendResult added in v1.1.0

func (r *Relayer[T]) SendResult(id string, result T)

SendResult will forward results to the channel returned by AwaitResult

type Relayers added in v1.1.0

type Relayers struct {
	Logs    *Relayer[[]*record.Log]
	Metrics *Relayer[[]*record.Metric]
	Traces  *Relayer[[]*record.Trace]
}

Relayers is a wrapper around multiple Relayer instances used for different types of results

func NewRelayers added in v1.1.0

func NewRelayers(logger *zap.Logger) *Relayers

NewRelayers returns a new set of Relayers

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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