Documentation
¶
Overview ¶
Package client is the typed Go client of the motte store and control planes.
Index ¶
- Constants
- Variables
- func CurrentRef(err error) (api.Ref, bool)
- type Client
- func (c *Client) Blobs(ctx context.Context, shas []string) ([][]byte, error)
- func (c *Client) Claim(ctx context.Context, workspace string, req api.ClaimRequest) (api.ClaimResponse, error)
- func (c *Client) Commit(ctx context.Context, sha string) (api.Commit, error)
- func (c *Client) CreateRepo(ctx context.Context, name, owner string) (string, error)
- func (c *Client) DeleteRef(ctx context.Context, name string, expect int64) error
- func (c *Client) DeleteWorkspace(ctx context.Context, workspace string) error
- func (c *Client) Flush(ctx context.Context, workspace string, req api.FlushRequest) error
- func (c *Client) Has(ctx context.Context, shas []string) ([]bool, error)
- func (c *Client) ImportPack(ctx context.Context, packID string, index, pack []byte) error
- func (c *Client) Object(ctx context.Context, sha string) (Object, error)
- func (c *Client) Op(ctx context.Context, kind, id string) ([]byte, error)
- func (c *Client) OpHeads(ctx context.Context) (api.OpHeads, error)
- func (c *Client) PutObjects(ctx context.Context, objs []Object) ([]string, error)
- func (c *Client) PutOp(ctx context.Context, kind, id string, data []byte) error
- func (c *Client) Ref(ctx context.Context, name string) (api.Ref, error)
- func (c *Client) Refs(ctx context.Context) ([]api.Ref, error)
- func (c *Client) Repo(ctx context.Context, path string) (api.Repo, error)
- func (c *Client) Repos(ctx context.Context) ([]api.Repo, error)
- func (c *Client) SetWorkspace(ctx context.Context, op, commit string, generation int64) error
- func (c *Client) SwapOpHeads(ctx context.Context, expectGeneration int64, heads []string) (api.OpHeads, error)
- func (c *Client) SwapRef(ctx context.Context, name string, expect int64, commit string) (api.Ref, error)
- func (c *Client) Trees(ctx context.Context, sha string, maxEntries int) (api.Trees, error)
- type Error
- type GrantFunc
- type Object
- type Option
Constants ¶
const DefaultBudget = 2 * time.Second
DefaultBudget is the time limit of one call unless WithBudget sets another.
Variables ¶
var ( ErrNotConfigured = errors.New("motte: not configured") ErrNotFound = errors.New("motte: not found") ErrGenerationConflict = errors.New("motte: generation conflict") ErrClaimLost = errors.New("motte: claim lost") ErrObjectInvalid = errors.New("motte: object invalid") ErrObjectTooLarge = errors.New("motte: object too large") ErrRepoForbidden = errors.New("motte: repository forbidden") ErrWorkspaceConflict = errors.New("motte: workspace conflict") ErrWorkspaceDeleted = errors.New("motte: workspace deleted") ErrInvalidBody = errors.New("motte: invalid body") ErrInternal = errors.New("motte: internal error") // ErrRedirect is the error of a 3xx answer. The client follows no redirect, so a grant never leaves the base URL. ErrRedirect = errors.New("motte: unexpected redirect") // ErrUnexpected is the error of a failure answer that carries no wire error body. ErrUnexpected = errors.New("motte: unexpected response") )
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls one store. A grant has one scope, so a caller holds one Client for each scope it uses. A Client is safe for concurrent use.
func (*Client) Claim ¶
func (c *Client) Claim(ctx context.Context, workspace string, req api.ClaimRequest) (api.ClaimResponse, error)
Claim binds or raises the epoch of a workspace and returns its stored state.
func (*Client) CreateRepo ¶
CreateRepo creates a repository with a root commit under main and returns its path.
func (*Client) DeleteWorkspace ¶
DeleteWorkspace deletes a workspace. It is idempotent.
func (*Client) ImportPack ¶
ImportPack stores a pack and its v2 index. packID is the lowercase hex SHA-256 of pack.
func (*Client) PutObjects ¶
PutObjects stores the objects and returns their names.
func (*Client) PutOp ¶
PutOp stores one op-log object of the workspace. kind is the op kind of the store.
func (*Client) SetWorkspace ¶
SetWorkspace reports the op and commit of the workspace. generation is that of the op-heads swap of op.
func (*Client) SwapOpHeads ¶
func (c *Client) SwapOpHeads(ctx context.Context, expectGeneration int64, heads []string) (api.OpHeads, error)
SwapOpHeads replaces the head set when the stored generation is expectGeneration. Use 0 for the first write.
func (*Client) SwapRef ¶
func (c *Client) SwapRef(ctx context.Context, name string, expect int64, commit string) (api.Ref, error)
SwapRef points the ref at commit when its stored generation is expect. Use 0 to create the ref. A conflict is ErrGenerationConflict, and CurrentRef returns the stored ref.
type Error ¶
type Error struct {
Status int
Code api.Code
Message string
Details map[string]any
// contains filtered or unexported fields
}
Error is a failure answer of the store. errors.Is matches the sentinel of its code.
type GrantFunc ¶
GrantFunc returns the bearer grant of one call. The client calls it before each request.
func StaticGrant ¶
StaticGrant returns a GrantFunc that always answers token.
type Option ¶
type Option func(*Client)
func WithBudget ¶
WithBudget sets the time limit of one call. Zero or less removes the limit; a deadline on the call context still applies.
func WithHTTPClient ¶
WithHTTPClient sets the transport. The client still follows no redirect.