daemon

package
v0.0.0-...-d39526f Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultSocketPath

func GetDefaultSocketPath() string

GetDefaultSocketPath returns the default socket path

func IsDaemonRunning

func IsDaemonRunning(socketPath string) bool

IsDaemonRunning checks if the daemon is running

Types

type Client

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

Client represents a client connection to the worklet daemon

func NewClient

func NewClient(socketPath string) *Client

NewClient creates a new daemon client

func (*Client) Close

func (c *Client) Close() error

Close closes the client connection

func (*Client) Connect

func (c *Client) Connect() error

Connect establishes a connection to the daemon

func (*Client) GetForkInfo

func (c *Client) GetForkInfo(ctx context.Context, forkID string) (*ForkInfo, error)

GetForkInfo returns information about a specific fork

func (*Client) GetVersion

func (c *Client) GetVersion(ctx context.Context) (*GetVersionResponse, error)

GetVersion returns the version information of the running daemon

func (*Client) HealthCheck

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

HealthCheck checks if the daemon is running

func (*Client) ListForks

func (c *Client) ListForks(ctx context.Context) ([]ForkInfo, error)

ListForks returns all registered forks

func (*Client) RefreshAll

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

RefreshAll refreshes information for all forks

func (*Client) RefreshFork

func (c *Client) RefreshFork(ctx context.Context, forkID string) error

RefreshFork refreshes information for a specific fork

func (*Client) RegisterFork

func (c *Client) RegisterFork(ctx context.Context, req RegisterForkRequest) error

RegisterFork registers a new fork with the daemon

func (*Client) RequestForkID

func (c *Client) RequestForkID(ctx context.Context) (string, error)

RequestForkID requests a new fork ID from the daemon

func (*Client) TriggerDiscovery

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

TriggerDiscovery triggers the daemon to discover containers immediately

func (*Client) UnregisterFork

func (c *Client) UnregisterFork(ctx context.Context, forkID string) error

UnregisterFork removes a fork registration from the daemon

type Daemon

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

Daemon represents the worklet daemon server

func NewDaemon

func NewDaemon(socketPath string) *Daemon

NewDaemon creates a new daemon instance

func (*Daemon) Start

func (d *Daemon) Start() error

Start starts the daemon server

func (*Daemon) Stop

func (d *Daemon) Stop() error

Stop stops the daemon server

type DaemonState

type DaemonState struct {
	NextForkID int `json:"next_fork_id"`
}

DaemonState represents the persistent state of the daemon

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
	Code  string `json:"code,omitempty"`
}

ErrorResponse is sent when an error occurs

type ForkInfo

type ForkInfo struct {
	ForkID       string            `json:"fork_id"`
	ProjectName  string            `json:"project_name"`
	ContainerID  string            `json:"container_id,omitempty"`
	WorkDir      string            `json:"work_dir"`
	Services     []ServiceInfo     `json:"services,omitempty"`
	Metadata     map[string]string `json:"metadata,omitempty"`
	RegisteredAt time.Time         `json:"registered_at"`
	LastSeenAt   time.Time         `json:"last_seen_at"`
}

ForkInfo contains information about a registered fork

type GetForkInfoRequest

type GetForkInfoRequest struct {
	ForkID string `json:"fork_id"`
}

GetForkInfoRequest requests information about a specific fork

type GetVersionResponse

type GetVersionResponse struct {
	Version   string `json:"version"`
	BuildTime string `json:"build_time,omitempty"`
	GitCommit string `json:"git_commit,omitempty"`
	StartTime string `json:"start_time,omitempty"`
}

GetVersionResponse contains version information

type ListForksResponse

type ListForksResponse struct {
	Forks []ForkInfo `json:"forks"`
}

ListForksResponse contains a list of all registered forks

type Message

type Message struct {
	Type    MessageType     `json:"type"`
	ID      string          `json:"id,omitempty"` // Request ID for correlation
	Payload json.RawMessage `json:"payload,omitempty"`
}

Message represents a message between client and daemon

type MessageType

type MessageType string

MessageType represents the type of message sent between client and daemon

const (
	// Client -> Daemon messages
	MsgRegisterFork     MessageType = "REGISTER_FORK"
	MsgUnregisterFork   MessageType = "UNREGISTER_FORK"
	MsgListForks        MessageType = "LIST_FORKS"
	MsgGetForkInfo      MessageType = "GET_FORK_INFO"
	MsgProxyRegister    MessageType = "PROXY_REGISTER"
	MsgHealthCheck      MessageType = "HEALTH_CHECK"
	MsgRefreshFork      MessageType = "REFRESH_FORK"
	MsgRefreshAll       MessageType = "REFRESH_ALL"
	MsgRequestForkID    MessageType = "REQUEST_FORK_ID"
	MsgTriggerDiscovery MessageType = "TRIGGER_DISCOVERY"
	MsgGetVersion       MessageType = "GET_VERSION"

	// Daemon -> Client responses
	MsgSuccess  MessageType = "SUCCESS"
	MsgError    MessageType = "ERROR"
	MsgForkList MessageType = "FORK_LIST"
	MsgForkInfo MessageType = "FORK_INFO"
	MsgForkID   MessageType = "FORK_ID"
	MsgVersion  MessageType = "VERSION"
)

type RefreshAllRequest

type RefreshAllRequest struct {
}

RefreshAllRequest is sent to refresh all forks

type RefreshForkRequest

type RefreshForkRequest struct {
	ForkID string `json:"fork_id"`
}

RefreshForkRequest is sent to refresh a specific fork's information

type RegisterForkRequest

type RegisterForkRequest struct {
	ForkID      string            `json:"fork_id"`
	ProjectName string            `json:"project_name"`
	ContainerID string            `json:"container_id,omitempty"`
	WorkDir     string            `json:"work_dir"`
	Services    []ServiceInfo     `json:"services,omitempty"`
	Metadata    map[string]string `json:"metadata,omitempty"`
}

RegisterForkRequest is sent when a new fork is created

type RequestForkIDResponse

type RequestForkIDResponse struct {
	ForkID string `json:"fork_id"`
}

RequestForkIDResponse contains the next available fork ID

type ServiceInfo

type ServiceInfo struct {
	Name      string `json:"name"`
	Port      int    `json:"port"`
	Subdomain string `json:"subdomain"`
}

ServiceInfo describes a service exposed by a fork

type SuccessResponse

type SuccessResponse struct {
	Message string `json:"message,omitempty"`
}

SuccessResponse is sent for successful operations

type UnregisterForkRequest

type UnregisterForkRequest struct {
	ForkID string `json:"fork_id"`
}

UnregisterForkRequest is sent when a fork is being removed

Jump to

Keyboard shortcuts

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