Documentation
¶
Overview ¶
Package oncehttp is a small client for the once HTTP API.
Index ¶
- Constants
- type Client
- func (c *Client) Commit(ctx context.Context, req CommitRequest) (Record, error)
- func (c *Client) Delete(ctx context.Context, key, attemptToken string, force bool) error
- func (c *Client) Get(ctx context.Context, key string) (Record, error)
- func (c *Client) Reserve(ctx context.Context, req ReserveRequest) (ReserveResponse, error)
- type CommitRequest
- type Error
- type Option
- type Record
- type ReserveRequest
- type ReserveResponse
- type State
Constants ¶
View Source
const DefaultMaxResponseBytes int64 = 16 << 20
DefaultMaxResponseBytes is the default cap for successful JSON responses.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to a once HTTP server.
func (*Client) Reserve ¶
func (c *Client) Reserve(ctx context.Context, req ReserveRequest) (ReserveResponse, error)
Reserve reserves a key or returns the existing record.
type CommitRequest ¶
type CommitRequest struct {
Key string `json:"key"`
AttemptToken string `json:"attempt_token"`
State State `json:"state"`
ExitCode int `json:"exit_code"`
Stdout []byte `json:"stdout_b64,omitempty"`
Stderr []byte `json:"stderr_b64,omitempty"`
Error string `json:"error,omitempty"`
}
CommitRequest commits a terminal result for a running key.
type Option ¶
Option configures a Client.
func WithBearerToken ¶
WithBearerToken configures HTTP bearer authentication.
func WithMaxResponseBytes ¶
WithMaxResponseBytes sets the maximum successful JSON response size.
type Record ¶
type Record struct {
Key string `json:"key"`
State State `json:"state"`
ExitCode int `json:"exit_code"`
Stdout []byte `json:"stdout_b64,omitempty"`
Stderr []byte `json:"stderr_b64,omitempty"`
Error string `json:"error,omitempty"`
Command []string `json:"command,omitempty"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
Record is the HTTP representation of one once idempotency record.
type ReserveRequest ¶
ReserveRequest reserves a key or fetches the existing record for that key.
type ReserveResponse ¶
type ReserveResponse struct {
Fresh bool `json:"fresh"`
AttemptToken string `json:"attempt_token,omitempty"`
Record Record `json:"record"`
}
ReserveResponse is returned by Reserve.
Click to show internal directories.
Click to hide internal directories.