agent

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const ProtocolVersion = "1"

Variables

View Source
var Version = "0.1.0"

Functions

func GenerateToken

func GenerateToken() (string, error)

func HashToken

func HashToken(token string) string

func VerifyToken

func VerifyToken(token, encodedHash string) bool

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config ClientConfig, source provider.Provider, logger *slog.Logger) (*Client, error)

func (*Client) Run

func (c *Client) Run(ctx context.Context) error

type ClientConfig

type ClientConfig struct {
	ServerURL          string
	ConnectionID       string
	Token              string
	Kind               string
	CAFile             string
	InsecureSkipVerify bool
	InventoryInterval  time.Duration
	HeartbeatInterval  time.Duration
	ReconnectMin       time.Duration
	ReconnectMax       time.Duration
	Metadata           map[string]string
	TemporaryTTL       time.Duration
}

type Command

type Command struct {
	ID            string              `json:"id"`
	Type          string              `json:"type"`
	StreamID      string              `json:"stream_id,omitempty"`
	Request       model.StreamRequest `json:"request,omitempty"`
	MetricRequest model.MetricRequest `json:"metric_request,omitempty"`
	CreatedAt     time.Time           `json:"created_at"`
}

func NewCommand

func NewCommand(commandType string) Command

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

func NewHub

func NewHub(state *store.Store) *Hub

func (*Hub) AttachCommands

func (h *Hub) AttachCommands(connectionID string) (<-chan Command, func())

func (*Hub) Authenticate

func (h *Hub) Authenticate(connectionID, token string) bool

func (*Hub) DebugString

func (h *Hub) DebugString(connectionID string) string

func (*Hub) HandleMessage

func (h *Hub) HandleMessage(connectionID string, message Message)

func (*Hub) Inventory

func (h *Hub) Inventory(connectionID string) (model.Inventory, bool)

func (*Hub) OpenMetricStream

func (h *Hub) OpenMetricStream(ctx context.Context, connectionID string, request model.MetricRequest, out chan<- model.WorkloadMetric) error

func (*Hub) OpenStream

func (h *Hub) OpenStream(ctx context.Context, connectionID string, request model.StreamRequest, out chan<- model.ActivityRecord) error

func (*Hub) RefreshInventory

func (h *Hub) RefreshInventory(connectionID string) error

func (*Hub) Status

func (h *Hub) Status(connectionID string) model.ConnectionStatus

type Message

type Message struct {
	ProtocolVersion string                `json:"protocol_version,omitempty"`
	Type            string                `json:"type"`
	ConnectionID    string                `json:"connection_id,omitempty"`
	AgentVersion    string                `json:"agent_version,omitempty"`
	AgentKind       string                `json:"agent_kind,omitempty"`
	Metadata        map[string]string     `json:"metadata,omitempty"`
	Inventory       *model.Inventory      `json:"inventory,omitempty"`
	StreamID        string                `json:"stream_id,omitempty"`
	Record          *model.ActivityRecord `json:"record,omitempty"`
	Metric          *model.WorkloadMetric `json:"metric,omitempty"`
	Error           string                `json:"error,omitempty"`
	Timestamp       time.Time             `json:"timestamp"`
}

type RemoteProviderFactory

type RemoteProviderFactory struct{ Hub *Hub }

func (*RemoteProviderFactory) ProviderForAgent

func (f *RemoteProviderFactory) ProviderForAgent(connection model.Connection) (provider.Provider, error)

Jump to

Keyboard shortcuts

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