consoleclient

package
v0.217.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 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 consoleclient is the WB daemon's HTTP client for Sneat Dev Console (spec/features/console-connect). Every failure is a typed console.ErrorCode; the text of a Console 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("console 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("console url must be https, or http on a loopback host, with no path")

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

Functions

func CodeOf

func CodeOf(err error) console.ErrorCode

CodeOf is the console.ErrorCode of err, or "" when err is not a Console failure.

Types

type Client

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

Client talks to one Console origin.

func New

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

New returns a client for the Console at rawURL.

func (*Client) Heartbeat

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

Heartbeat sends the periodic liveness signal.

func (*Client) Publish

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

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

func (*Client) Revoke

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

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

func (*Client) Self

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

Self reads Console'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) (console.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 console.ErrorCode
	// RetryAfter is Console's Retry-After for rate_limited, zero when absent.
	RetryAfter time.Duration
	// MinimumSchemaVersion is the version Console requires for schema_unsupported.
	MinimumSchemaVersion int
}

Error is a typed Console 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