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
- Variables
- func CodeOf(err error) console.ErrorCode
- type Client
- func (client *Client) Heartbeat(ctx context.Context, request console.HeartbeatRequest) error
- func (client *Client) Publish(ctx context.Context, request console.SnapshotRequest) (console.SnapshotReceipt, error)
- func (client *Client) Revoke(ctx context.Context) error
- func (client *Client) Self(ctx context.Context) (console.MachineSelf, error)
- func (client *Client) Start(ctx context.Context, request console.ConnectStartRequest) (console.ConnectStartResponse, error)
- func (client *Client) Token(ctx context.Context, deviceCode string) (console.ConnectTokenResponse, error)
- type Error
- type Options
Constants ¶
const ( DefaultConnectTimeout = 10 * time.Second DefaultTotalTimeout = 30 * time.Second )
Default timeouts.
Variables ¶
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.
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 ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to one Console origin.
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 ¶
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) Start ¶
func (client *Client) Start(ctx context.Context, request console.ConnectStartRequest) (console.ConnectStartResponse, error)
Start opens a device grant (unauthenticated).
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.
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.