agentapi

package
v2.18.5 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WatchWorkspaceAgentMetadataChannel

func WatchWorkspaceAgentMetadataChannel(id uuid.UUID) string

func WithAPIVersion added in v2.8.0

func WithAPIVersion(ctx context.Context, version string) context.Context

Types

type API

type API struct {
	*ManifestAPI
	*AnnouncementBannerAPI
	*StatsAPI
	*LifecycleAPI
	*AppsAPI
	*MetadataAPI
	*LogsAPI
	*ScriptsAPI
	*tailnet.DRPCService
	// contains filtered or unexported fields
}

API implements the DRPC agent API interface from agent/proto. This struct is instantiated once per agent connection and kept alive for the duration of the session.

func New

func New(opts Options) *API

func (*API) Serve

func (a *API) Serve(ctx context.Context, l net.Listener) error

func (*API) Server

func (a *API) Server(ctx context.Context) (*drpcserver.Server, error)

type AnnouncementBannerAPI added in v2.12.0

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

func (*AnnouncementBannerAPI) GetAnnouncementBanners added in v2.12.0

func (*AnnouncementBannerAPI) GetServiceBanner deprecated added in v2.12.0

Deprecated: GetServiceBanner has been deprecated in favor of GetAnnouncementBanners.

type AppsAPI

type AppsAPI struct {
	AgentFn                  func(context.Context) (database.WorkspaceAgent, error)
	Database                 database.Store
	Log                      slog.Logger
	PublishWorkspaceUpdateFn func(context.Context, *database.WorkspaceAgent, wspubsub.WorkspaceEventKind) error
}

type LifecycleAPI

type LifecycleAPI struct {
	AgentFn                  func(context.Context) (database.WorkspaceAgent, error)
	WorkspaceID              uuid.UUID
	Database                 database.Store
	Log                      slog.Logger
	PublishWorkspaceUpdateFn func(context.Context, *database.WorkspaceAgent, wspubsub.WorkspaceEventKind) error

	TimeNowFn func() time.Time // defaults to dbtime.Now()
}

func (*LifecycleAPI) UpdateLifecycle

func (*LifecycleAPI) UpdateStartup

type LogsAPI

type LogsAPI struct {
	AgentFn                           func(context.Context) (database.WorkspaceAgent, error)
	Database                          database.Store
	Log                               slog.Logger
	PublishWorkspaceUpdateFn          func(context.Context, *database.WorkspaceAgent, wspubsub.WorkspaceEventKind) error
	PublishWorkspaceAgentLogsUpdateFn func(ctx context.Context, workspaceAgentID uuid.UUID, msg agentsdk.LogsNotifyMessage)

	TimeNowFn func() time.Time // defaults to dbtime.Now()
}

type ManifestAPI

type ManifestAPI struct {
	AccessURL                *url.URL
	AppHostname              string
	ExternalAuthConfigs      []*externalauth.Config
	DisableDirectConnections bool
	DerpForceWebSockets      bool
	WorkspaceID              uuid.UUID

	AgentFn   func(context.Context) (database.WorkspaceAgent, error)
	Database  database.Store
	DerpMapFn func() *tailcfg.DERPMap
}

func (*ManifestAPI) GetManifest

type MetadataAPI

type MetadataAPI struct {
	AgentFn  func(context.Context) (database.WorkspaceAgent, error)
	Database database.Store
	Pubsub   pubsub.Pubsub
	Log      slog.Logger

	TimeNowFn func() time.Time // defaults to dbtime.Now()
}

type Options

type Options struct {
	AgentID     uuid.UUID
	OwnerID     uuid.UUID
	WorkspaceID uuid.UUID

	Ctx                               context.Context
	Log                               slog.Logger
	Database                          database.Store
	Pubsub                            pubsub.Pubsub
	DerpMapFn                         func() *tailcfg.DERPMap
	TailnetCoordinator                *atomic.Pointer[tailnet.Coordinator]
	StatsReporter                     *workspacestats.Reporter
	AppearanceFetcher                 *atomic.Pointer[appearance.Fetcher]
	PublishWorkspaceUpdateFn          func(ctx context.Context, userID uuid.UUID, event wspubsub.WorkspaceEvent)
	PublishWorkspaceAgentLogsUpdateFn func(ctx context.Context, workspaceAgentID uuid.UUID, msg agentsdk.LogsNotifyMessage)
	NetworkTelemetryHandler           func(batch []*tailnetproto.TelemetryEvent)

	AccessURL                 *url.URL
	AppHostname               string
	AgentStatsRefreshInterval time.Duration
	DisableDirectConnections  bool
	DerpForceWebSockets       bool
	DerpMapUpdateFrequency    time.Duration
	ExternalAuthConfigs       []*externalauth.Config
	Experiments               codersdk.Experiments

	UpdateAgentMetricsFn func(ctx context.Context, labels prometheusmetrics.AgentMetricLabels, metrics []*agentproto.Stats_Metric)
}

type ScriptsAPI added in v2.16.0

type ScriptsAPI struct {
	Database database.Store
}

type StatsAPI

type StatsAPI struct {
	AgentFn                   func(context.Context) (database.WorkspaceAgent, error)
	Database                  database.Store
	Log                       slog.Logger
	StatsReporter             *workspacestats.Reporter
	AgentStatsRefreshInterval time.Duration
	Experiments               codersdk.Experiments

	TimeNowFn func() time.Time // defaults to dbtime.Now()
}

func (*StatsAPI) UpdateStats

type WorkspaceAgentMetadataChannelPayload

type WorkspaceAgentMetadataChannelPayload struct {
	CollectedAt time.Time `json:"collected_at"`
	Keys        []string  `json:"keys"`
}

Jump to

Keyboard shortcuts

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