Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) DiscardTasks(ctx context.Context, taskIDs []TaskID) error
- func (c *Client) Kill(ctx context.Context, processID ProcessID) error
- func (c *Client) Logger() *log.Logger
- func (c *Client) LookupTasks(ctx context.Context, taskIDs []TaskID) ([]TaskResponse, error)
- func (c *Client) PollTasks(ctx context.Context, batchSize int, timeout time.Duration) ([]TaskResponse, error)
- func (c *Client) ProcessID(ctx context.Context) (ProcessID, error)
- func (c *Client) Spawn(ctx context.Context, module ModuleSpec) (ProcessID, netip.Addr, error)
- func (c *Client) SubmitTasks(ctx context.Context, requests []TaskRequest) ([]TaskID, error)
- func (c *Client) Version(ctx context.Context) (string, error)
- type HTTPRequest
- type HTTPResponse
- type ModuleSpec
- type ProcessID
- type TaskID
- type TaskInput
- type TaskOutput
- type TaskRequest
- type TaskResponse
- type TaskState
Constants ¶
const TimecraftAddress = "127.0.0.1:7463"
TimecraftAddress is the socket that timecraft guests connect to in order to interact with the timecraft runtime on the host. Note that this is a virtual socket.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a timecraft client.
func (*Client) DiscardTasks ¶
DiscardTasks discards a batch of tasks by ID.
func (*Client) LookupTasks ¶
LookupTasks retrieves task responses by ID.
func (*Client) PollTasks ¶
func (c *Client) PollTasks(ctx context.Context, batchSize int, timeout time.Duration) ([]TaskResponse, error)
PollTasks retrieves tasks that are complete.
Tasks are complete when task execution either succeeds or fails permanently.
PollTasks will block the goroutine until either batchSize tasks are complete, or the timeout is reached, whichever comes first. If timeout is zero, the timecraft runtime won't block waiting for complete tasks. If the timeout is less than zero, the method will block until batchSize tasks are complete (and thus may block indefinitely).
func (*Client) SubmitTasks ¶
SubmitTasks submits tasks to the timecraft runtime.
The tasks are executed asynchronously. The method returns a set of TaskID that can be used to query task status and fetch task output when ready.
type HTTPRequest ¶
HTTPRequest is an HTTP request.
type HTTPResponse ¶
HTTPResponse is an HTTP response.
type ModuleSpec ¶
type ModuleSpec struct { Path string Function string Args []string Env []string OutboundProxy *ModuleSpec }
ModuleSpec is a WebAssembly module specification.
type TaskInput ¶
type TaskInput interface {
// contains filtered or unexported methods
}
TaskInput is input to a task.
type TaskOutput ¶
type TaskOutput interface {
// contains filtered or unexported methods
}
TaskOutput is output from a task.
type TaskRequest ¶
type TaskRequest struct { // Module is details about the WebAssembly module that's responsible // for executing the task. Module ModuleSpec // Input is input to the task. Input TaskInput }
TaskRequest is a request to the timecraft runtime asking it to schedule a task for execution.
type TaskResponse ¶
type TaskResponse struct { // ID is the task identifier. ID TaskID // State is the current state of the task. State TaskState // Error is the error that occurred during task initialization or execution // (if applicable). Error error // Output is the output of the task, if it executed successfully. Output TaskOutput // ProcessID is the identifier of the process that handled the task // (if applicable). ProcessID ProcessID }
TaskResponse is information about a task from the timecraft runtime.
type TaskState ¶
type TaskState int
TaskState is the state of a task.
const ( // Queued indicates that the task is waiting to be scheduled. Queued TaskState = iota + 1 // Initializing indicates that the task is in the process of being scheduled // on to a process. Initializing // Executing indicates that the task is currently being executed. Executing // Error indicates that the task failed with an error. This is a terminal // status. Error // Success indicates that the task executed successfully. This is a terminal // status. Success )