Documentation ¶
Overview ¶
Package client implements a client for the HTTP taskstore service.
Index ¶
- func ID() int32
- type HTTPClient
- func (h *HTTPClient) Claim(group string, duration int64, depends []int64) (*protocol.TaskInfo, error)
- func (h *HTTPClient) Group(name string, limit int, owned bool) ([]protocol.TaskInfo, error)
- func (h *HTTPClient) Groups() ([]string, error)
- func (h *HTTPClient) Task(id int64) (*protocol.TaskInfo, error)
- func (h *HTTPClient) Tasks(ids ...int64) ([]protocol.TaskInfo, error)
- func (h *HTTPClient) Update(adds, updates []protocol.TaskInfo, deletes, depends []int64) ([]protocol.TaskInfo, error)
- type HTTPError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
An HTTPClient provides access to a particular taskstore HTTP service, as specified by a URL.
func NewHTTPClient ¶
func NewHTTPClient(baseURL string) *HTTPClient
NewHTTPClient creates an HTTPClient that attempts to connect to the given base URL for all operations.
func (*HTTPClient) Claim ¶
func (h *HTTPClient) Claim(group string, duration int64, depends []int64) (*protocol.TaskInfo, error)
Claim attempts to claim a task from the given group. If successful, the task returned will be leaesed for an additional duration nanoseconds before ownership expirees. The operation will only succeed if all task IDs in depends exist in the task store. A nil value indicates no dependencies.
The task returned may be nil, indicating that no tasks were available to be claimed, but otherwise no errors occurred. If the error returned is of type TaskResponseError, then it will be a slice of errors, one for each unsatisifed task constraint (e.g., a missing dependency).
func (*HTTPClient) Group ¶
Group retrieves the tasks for the given group. Optionally, a limit greater than zero indicates a maximum number of tasks that can be retrieved. If owned tasks should also be retrieved, set owned. Otherwise only tasks with an arrival time in the past will be returned. Note that allowing owned tasks does not discriminate by owner ID. All owned tasks will be allowed regardless of who owns them.
func (*HTTPClient) Groups ¶
func (h *HTTPClient) Groups() ([]string, error)
Groups retrieves a list of group names from the task service.
func (*HTTPClient) Task ¶
func (h *HTTPClient) Task(id int64) (*protocol.TaskInfo, error)
Task retrieves the task for the given ID, if it exists.
func (*HTTPClient) Tasks ¶
func (h *HTTPClient) Tasks(ids ...int64) ([]protocol.TaskInfo, error)
Tasks retrieves the tasks for the given list of IDs.
func (*HTTPClient) Update ¶
func (h *HTTPClient) Update(adds, updates []protocol.TaskInfo, deletes, depends []int64) ([]protocol.TaskInfo, error)
Update attempts to add, update, and delete the specified tasks, provided that all dependencies are met and the operation can be completed atomically and by the appropriate owner, etc.
If successful, it returns a slice of tasks, appropriately updated (with new IDs). Otherwise, it returns an error. If the error is of type TaskResponseError, it means that the request succeeded, but the operation could not complete due to normal task store function: it is a slice of errors describing all of the failed constraints or dependencies that led to no update occurring.