agent

package
v0.0.0-...-8bf0aa5 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAuthTokenNotFound is returned when the auth token is not found
	// in the database indicating that the agent does not have a token.
	ErrAuthTokenNotFound = errors.New("auth token not found")
	ErrNoAgentID         = errors.New("no agent id")
)

Functions

func NewLifecycleNotifications

func NewLifecycleNotifications(lc fx.Lifecycle, client *Client, logger *zap.Logger)

func NewServer

func NewServer(logger *zap.Logger, tomb *tomb.Tomb) rpc.AgentServer

Types

type AuthToken

type AuthToken struct {
	Token      string
	Expiration time.Time
	Duration   time.Duration
}

type Client

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

func NewClient

func NewClient(
	ctx context.Context,
	config *Config,
	tomb *tomb.Tomb,
	cmd *cobra.Command,
	db Database,
	logger *zap.Logger,
	service rpc.AgentServer,
	metadataProvider SystemMetadataProvider,
) *Client

func (*Client) Notify

func (c *Client) Notify(ctx context.Context, notification *rpc.ClientNotification) error

func (*Client) Ping

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

type Config

type Config struct {
	Server       server
	Logging      Logging
	Database     database
	PreSharedKey string `yaml:"preSharedKey"`
}

func NewConfig

func NewConfig(cmd *cobra.Command) (*Config, error)

type Database

type Database interface {
	AuthToken(ctx context.Context) (*AuthToken, error)
	SaveAuthToken(ctx context.Context, token *AuthToken) error

	AgentID(ctx context.Context) (string, error)
	SaveAgentID(ctx context.Context, agentID string) error
}

func NewDatabase

func NewDatabase(cfg *Config) (Database, error)

type Logging

type Logging struct {
	Level string `json:"level"`
	Debug bool   `json:"debug"`
}

type Server

type Server struct {
	rpc.UnimplementedAgentServer
	// contains filtered or unexported fields
}

Server is the gRPC server that runs on the agent itself and is accessible by the real gRPC server that the agent connects to.

func (*Server) Shutdown

type SystemMetadataProvider

type SystemMetadataProvider interface {
	GetSystemMetadata(ctx context.Context) (*rpc.SystemMetadata, error)
}

Jump to

Keyboard shortcuts

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