Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) AddContextSource(ctx context.Context, path string) (ContextSource, error)
- func (c *Client) Close() error
- func (c *Client) ContextSources(ctx context.Context) ([]ContextSource, error)
- func (c *Client) GetContextSnapshot(ctx context.Context) (ContextSnapshot, error)
- func (c *Client) GetContextSource(ctx context.Context, path string) (ContextSource, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) RemoveContextSource(ctx context.Context, path string) error
- func (c *Client) ResyncContext(ctx context.Context) (ContextSnapshot, error)
- func (c *Client) SyncComplete(ctx context.Context, unitName unit.ID) error
- func (c *Client) SyncList(ctx context.Context) ([]SyncListItem, error)
- func (c *Client) SyncReady(ctx context.Context, unitName unit.ID) (bool, error)
- func (c *Client) SyncStart(ctx context.Context, unitName unit.ID) error
- func (c *Client) SyncStatus(ctx context.Context, unitName unit.ID) (SyncStatusResponse, error)
- func (c *Client) SyncWant(ctx context.Context, unitName, dependsOn unit.ID) error
- func (c *Client) UpdateAppStatus(ctx context.Context, req *agentproto.UpdateAppStatusRequest) (*agentproto.UpdateAppStatusResponse, error)
- type ContextManager
- type ContextResource
- type ContextSnapshot
- type ContextSource
- type DRPCAgentSocketService
- func (s *DRPCAgentSocketService) AddContextSource(_ context.Context, req *proto.AddContextSourceRequest) (*proto.AddContextSourceResponse, error)
- func (s *DRPCAgentSocketService) ClearAgentAPI()
- func (s *DRPCAgentSocketService) ContextSources(_ context.Context, _ *proto.ContextSourcesRequest) (*proto.ContextSourcesResponse, error)
- func (s *DRPCAgentSocketService) GetContextSnapshot(_ context.Context, _ *proto.ContextSnapshotRequest) (*proto.ContextSnapshotResponse, error)
- func (s *DRPCAgentSocketService) GetContextSource(_ context.Context, req *proto.GetContextSourceRequest) (*proto.GetContextSourceResponse, error)
- func (*DRPCAgentSocketService) Ping(_ context.Context, _ *proto.PingRequest) (*proto.PingResponse, error)
- func (s *DRPCAgentSocketService) RemoveContextSource(_ context.Context, req *proto.RemoveContextSourceRequest) (*proto.RemoveContextSourceResponse, error)
- func (s *DRPCAgentSocketService) ResyncContext(ctx context.Context, _ *proto.ResyncContextRequest) (*proto.ResyncContextResponse, error)
- func (s *DRPCAgentSocketService) SetAgentAPI(api agentproto.DRPCAgentClient28)
- func (s *DRPCAgentSocketService) SyncComplete(_ context.Context, req *proto.SyncCompleteRequest) (*proto.SyncCompleteResponse, error)
- func (s *DRPCAgentSocketService) SyncList(_ context.Context, _ *proto.SyncListRequest) (*proto.SyncListResponse, error)
- func (s *DRPCAgentSocketService) SyncReady(_ context.Context, req *proto.SyncReadyRequest) (*proto.SyncReadyResponse, error)
- func (s *DRPCAgentSocketService) SyncStart(_ context.Context, req *proto.SyncStartRequest) (*proto.SyncStartResponse, error)
- func (s *DRPCAgentSocketService) SyncStatus(_ context.Context, req *proto.SyncStatusRequest) (*proto.SyncStatusResponse, error)
- func (s *DRPCAgentSocketService) SyncWant(_ context.Context, req *proto.SyncWantRequest) (*proto.SyncWantResponse, error)
- func (s *DRPCAgentSocketService) UpdateAppStatus(ctx context.Context, req *agentproto.UpdateAppStatusRequest) (*agentproto.UpdateAppStatusResponse, error)
- type DependencyInfo
- type Option
- type Server
- type SyncListItem
- type SyncStatusResponse
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnitManagerNotAvailable = xerrors.New("unit manager not available") ErrAgentAPINotConnected = xerrors.New("agent not connected to coderd") ErrContextManagerNotAvailable = xerrors.New("context manager not available") ErrContextSourceNotFound = xerrors.New("context source not found") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides a client for communicating with the workspace agentsocket API.
func NewClient ¶
NewClient creates a new socket client and opens a connection to the socket. If path is not provided via WithPath or is empty, it will auto-discover the default socket path.
func (*Client) AddContextSource ¶ added in v2.35.0
AddContextSource registers a new scan root on the agent.
func (*Client) ContextSources ¶ added in v2.35.0
func (c *Client) ContextSources(ctx context.Context) ([]ContextSource, error)
ContextSources lists the workspace-context sources registered on the agent.
func (*Client) GetContextSnapshot ¶ added in v2.35.0
func (c *Client) GetContextSnapshot(ctx context.Context) (ContextSnapshot, error)
GetContextSnapshot returns the agent's current resolved snapshot without forcing a re-walk.
func (*Client) GetContextSource ¶ added in v2.35.0
GetContextSource returns a single registered source. The path is canonicalized by the agent before matching.
func (*Client) RemoveContextSource ¶ added in v2.35.0
RemoveContextSource removes a previously-registered scan root.
func (*Client) ResyncContext ¶ added in v2.35.0
func (c *Client) ResyncContext(ctx context.Context) (ContextSnapshot, error)
ResyncContext forces a re-walk and synchronous push, returning the resulting snapshot. Use it as a barrier before fanning out a refresh.
func (*Client) SyncComplete ¶
SyncComplete marks a unit as complete in the dependency graph.
func (*Client) SyncList ¶ added in v2.35.0
func (c *Client) SyncList(ctx context.Context) ([]SyncListItem, error)
SyncList returns all registered units and their current statuses.
func (*Client) SyncReady ¶
SyncReady requests whether a unit is ready to be started. That is, all dependencies are satisfied.
func (*Client) SyncStatus ¶
SyncStatus gets the status of a unit and its dependencies.
func (*Client) UpdateAppStatus ¶ added in v2.32.0
func (c *Client) UpdateAppStatus(ctx context.Context, req *agentproto.UpdateAppStatusRequest) (*agentproto.UpdateAppStatusResponse, error)
UpdateAppStatus forwards an app status update to coderd via the agent.
type ContextManager ¶ added in v2.35.0
type ContextManager interface {
Sources() []agentcontext.Source
HasSource(path string) (canonical string, ok bool)
AddSource(s agentcontext.Source) (agentcontext.Source, error)
RemoveSource(path string) error
Snapshot() agentcontext.Snapshot
Resync(ctx context.Context) (agentcontext.Snapshot, error)
}
ContextManager is the subset of *agentcontext.Manager the socket service needs to serve workspace-context source CRUD. It is an interface so tests can supply a fake.
type ContextResource ¶ added in v2.35.0
type ContextResource struct {
Kind string `table:"kind,default_sort" json:"kind"`
Name string `table:"name" json:"name"`
Source string `table:"source" json:"source"`
SourcePath string `table:"source path" json:"source_path"`
Status string `table:"status" json:"status"`
SizeBytes uint64 `table:"size bytes" json:"size_bytes"`
Error string `table:"error" json:"error"`
Description string `table:"-" json:"description"`
ID string `table:"-" json:"id"`
ContentHash string `table:"-" json:"content_hash"`
}
ContextResource is a resolved workspace-context resource. Payload bytes are never carried over the socket.
type ContextSnapshot ¶ added in v2.35.0
type ContextSnapshot struct {
Version uint64 `json:"version"`
AggregateHash string `json:"aggregate_hash"`
Resources []ContextResource `json:"resources"`
PayloadBytes uint64 `json:"payload_bytes"`
SnapshotError string `json:"snapshot_error"`
}
ContextSnapshot is the agent's resolved workspace-context state.
type ContextSource ¶ added in v2.35.0
type ContextSource struct {
Path string `table:"path,default_sort" json:"path"`
}
ContextSource is a registered workspace-context scan root.
type DRPCAgentSocketService ¶
type DRPCAgentSocketService struct {
// contains filtered or unexported fields
}
DRPCAgentSocketService implements the DRPC agent socket service.
func (*DRPCAgentSocketService) AddContextSource ¶ added in v2.35.0
func (s *DRPCAgentSocketService) AddContextSource(_ context.Context, req *proto.AddContextSourceRequest) (*proto.AddContextSourceResponse, error)
AddContextSource registers a new scan root and triggers a re-resolve.
func (*DRPCAgentSocketService) ClearAgentAPI ¶ added in v2.32.0
func (s *DRPCAgentSocketService) ClearAgentAPI()
ClearAgentAPI clears the agent API client. This is called when the agent disconnects from coderd.
func (*DRPCAgentSocketService) ContextSources ¶ added in v2.35.0
func (s *DRPCAgentSocketService) ContextSources(_ context.Context, _ *proto.ContextSourcesRequest) (*proto.ContextSourcesResponse, error)
ContextSources lists the workspace-context sources registered on the agent.
func (*DRPCAgentSocketService) GetContextSnapshot ¶ added in v2.35.0
func (s *DRPCAgentSocketService) GetContextSnapshot(_ context.Context, _ *proto.ContextSnapshotRequest) (*proto.ContextSnapshotResponse, error)
GetContextSnapshot returns the agent's current resolved snapshot without forcing a re-walk.
func (*DRPCAgentSocketService) GetContextSource ¶ added in v2.35.0
func (s *DRPCAgentSocketService) GetContextSource(_ context.Context, req *proto.GetContextSourceRequest) (*proto.GetContextSourceResponse, error)
GetContextSource returns a single registered source, canonicalizing the requested path before matching.
func (*DRPCAgentSocketService) Ping ¶
func (*DRPCAgentSocketService) Ping(_ context.Context, _ *proto.PingRequest) (*proto.PingResponse, error)
Ping responds to a ping request to check if the service is alive.
func (*DRPCAgentSocketService) RemoveContextSource ¶ added in v2.35.0
func (s *DRPCAgentSocketService) RemoveContextSource(_ context.Context, req *proto.RemoveContextSourceRequest) (*proto.RemoveContextSourceResponse, error)
RemoveContextSource removes a previously-registered scan root.
func (*DRPCAgentSocketService) ResyncContext ¶ added in v2.35.0
func (s *DRPCAgentSocketService) ResyncContext(ctx context.Context, _ *proto.ResyncContextRequest) (*proto.ResyncContextResponse, error)
ResyncContext forces a re-walk and synchronous push, returning the resulting snapshot. Callers use it as a barrier before fanning out a refresh.
func (*DRPCAgentSocketService) SetAgentAPI ¶ added in v2.32.0
func (s *DRPCAgentSocketService) SetAgentAPI(api agentproto.DRPCAgentClient28)
SetAgentAPI sets the agent API client used to forward requests to coderd. This is called when the agent connects to coderd.
func (*DRPCAgentSocketService) SyncComplete ¶
func (s *DRPCAgentSocketService) SyncComplete(_ context.Context, req *proto.SyncCompleteRequest) (*proto.SyncCompleteResponse, error)
SyncComplete marks a unit as complete in the dependency graph.
func (*DRPCAgentSocketService) SyncList ¶ added in v2.35.0
func (s *DRPCAgentSocketService) SyncList(_ context.Context, _ *proto.SyncListRequest) (*proto.SyncListResponse, error)
SyncList returns all registered units and their current statuses.
func (*DRPCAgentSocketService) SyncReady ¶
func (s *DRPCAgentSocketService) SyncReady(_ context.Context, req *proto.SyncReadyRequest) (*proto.SyncReadyResponse, error)
SyncReady checks whether a unit is ready to be started. That is, all dependencies are satisfied.
func (*DRPCAgentSocketService) SyncStart ¶
func (s *DRPCAgentSocketService) SyncStart(_ context.Context, req *proto.SyncStartRequest) (*proto.SyncStartResponse, error)
SyncStart starts a unit in the dependency graph.
func (*DRPCAgentSocketService) SyncStatus ¶
func (s *DRPCAgentSocketService) SyncStatus(_ context.Context, req *proto.SyncStatusRequest) (*proto.SyncStatusResponse, error)
SyncStatus gets the status of a unit and lists its dependencies.
func (*DRPCAgentSocketService) SyncWant ¶
func (s *DRPCAgentSocketService) SyncWant(_ context.Context, req *proto.SyncWantRequest) (*proto.SyncWantResponse, error)
SyncWant declares a dependency between units.
func (*DRPCAgentSocketService) UpdateAppStatus ¶ added in v2.32.0
func (s *DRPCAgentSocketService) UpdateAppStatus(ctx context.Context, req *agentproto.UpdateAppStatusRequest) (*agentproto.UpdateAppStatusResponse, error)
UpdateAppStatus forwards an app status update to coderd via the agent API. Returns an error if the agent is not connected.
type DependencyInfo ¶
type DependencyInfo struct {
DependsOn unit.ID `table:"depends on,default_sort" json:"depends_on"`
RequiredStatus unit.Status `table:"required status" json:"required_status"`
CurrentStatus unit.Status `table:"current status" json:"current_status"`
IsSatisfied bool `table:"satisfied" json:"is_satisfied"`
}
DependencyInfo contains information about a unit dependency.
type Option ¶
type Option func(*options)
Option represents a configuration option for NewClient.
func WithContextManager ¶ added in v2.35.0
func WithContextManager(cm ContextManager) Option
WithContextManager supplies the workspace-context Manager the server uses to serve context source CRUD. Server-only; ignored by the client.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server provides access to the DRPCAgentSocketService via a Unix domain socket. Do not invoke Server{} directly. Use NewServer() instead.
func (*Server) ClearAgentAPI ¶ added in v2.32.0
func (s *Server) ClearAgentAPI()
ClearAgentAPI clears the agent API client.
func (*Server) SetAgentAPI ¶ added in v2.32.0
func (s *Server) SetAgentAPI(api agentproto.DRPCAgentClient28)
SetAgentAPI sets the agent API client used to forward requests to coderd.
type SyncListItem ¶ added in v2.35.0
type SyncListItem struct {
UnitName unit.ID `table:"unit,default_sort" json:"unit_name"`
Status unit.Status `table:"status" json:"status"`
IsReady bool `table:"ready" json:"is_ready"`
}
SyncListItem contains summary information for a single unit.
type SyncStatusResponse ¶
type SyncStatusResponse struct {
UnitName unit.ID `table:"unit,default_sort" json:"unit_name"`
Status unit.Status `table:"status" json:"status"`
IsReady bool `table:"ready" json:"is_ready"`
Dependencies []DependencyInfo `table:"dependencies" json:"dependencies"`
}
SyncStatusResponse contains the status information for a unit.