deskclient

package
v0.212.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package deskclient is the WB daemon's HTTP client for Sneat Dev Desk (spec/features/desk-connect). Every failure is a typed desk.ErrorCode; the text of a Desk response is never kept.

Index

Constants

View Source
const (
	DefaultConnectTimeout = 10 * time.Second
	DefaultTotalTimeout   = 30 * time.Second
)

Default timeouts.

Variables

View Source
var ErrCredential = errors.New("desk credential file must be one private token")

ErrCredential is returned when the credential file is missing, not private, or not one token.

View Source
var ErrInvalidURL = errors.New("desk url must be https, or http on a loopback host, with no path")

ErrInvalidURL is returned for a Desk address a credential may not be sent to.

Functions

func CodeOf

func CodeOf(err error) desk.ErrorCode

CodeOf is the desk.ErrorCode of err, or "" when err is not a Desk failure.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to one Desk origin.

func New

func New(rawURL string, options Options) (*Client, error)

New returns a client for the Desk at rawURL.

func (*Client) Heartbeat

func (client *Client) Heartbeat(ctx context.Context, request desk.HeartbeatRequest) error

Heartbeat sends the periodic liveness signal.

func (*Client) Publish

func (client *Client) Publish(ctx context.Context, request desk.SnapshotRequest) (desk.SnapshotReceipt, error)

Publish sends a snapshot gzip-encoded, refusing locally one over the bounds (desk-connect#req:bounded-payload).

func (*Client) Revoke

func (client *Client) Revoke(ctx context.Context) error

Revoke deletes this machine's credential at Desk. A 404 means Desk no longer has the machine, which is what revoking asks for.

func (*Client) Self

func (client *Client) Self(ctx context.Context) (desk.MachineSelf, error)

Self reads Desk's record of this machine.

func (*Client) Start

Start opens a device grant (unauthenticated).

func (*Client) Token

func (client *Client) Token(ctx context.Context, deviceCode string) (desk.ConnectTokenResponse, error)

Token polls a device grant (unauthenticated). A grant error is a normal answer: it comes back in the response, not as an error.

type Error

type Error struct {
	Code desk.ErrorCode
	// RetryAfter is Desk's Retry-After for rate_limited, zero when absent.
	RetryAfter time.Duration
	// MinimumSchemaVersion is the version Desk requires for schema_unsupported.
	MinimumSchemaVersion int
}

Error is a typed Desk failure.

func (*Error) Error

func (err *Error) Error() string

type Options

type Options struct {
	// CredentialFile holds the machine credential; empty for the unauthenticated
	// connect routes only.
	CredentialFile string
	Connect        time.Duration
	Total          time.Duration
	// Transport replaces the default transport (tests).
	Transport http.RoundTripper
}

Options configures a Client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL