Documentation
¶
Index ¶
- type Client
- func (c *Client) CancelTask(ctx context.Context, id uuid.UUID) (*schema.Status, error)
- func (c *Client) GetTask(ctx context.Context, id uuid.UUID) (*schema.Status, error)
- func (c *Client) ListTasks(ctx context.Context, req schema.TaskListRequest) (*schema.TaskList, error)
- func (c *Client) SubscribeEvents(ctx context.Context, req schema.TaskEventRequest, fn TaskEventFunc) error
- type TaskEventFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a task HTTP client that wraps the base HTTP client
func New ¶
New creates a new task HTTP client with the given base URL and options. The url parameter should point to the task API endpoint, e.g. "http://localhost:8080/api".
func (*Client) CancelTask ¶
CancelTask cancels the task with the given uuid. It's a no-op if the task has already finished or was never started. Returns the task's status after the cancellation request.
func (*Client) ListTasks ¶
func (c *Client) ListTasks(ctx context.Context, req schema.TaskListRequest) (*schema.TaskList, error)
ListTasks returns the tasks matching req, in the order they were added.
func (*Client) SubscribeEvents ¶
func (c *Client) SubscribeEvents(ctx context.Context, req schema.TaskEventRequest, fn TaskEventFunc) error
SubscribeEvents streams task events matching req - see schema.TaskEventRequest for how uuid and event filter the stream. It blocks, calling fn for every event, until ctx is done, the server stops, or fn itself stops it (io.EOF to stop cleanly, any other error to stop and have SubscribeEvents return that error).
type TaskEventFunc ¶
TaskEventFunc is called for every task event received from SubscribeEvents. Return io.EOF to stop the subscription cleanly, or any other error to stop it and have SubscribeEvents return that error.