client

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package client is the document plane's remote adapter: a document.Port implemented over the sheet API, so a frontend that can edit a local file can edit a document on a server without knowing the difference.

Its whole job is fidelity. Every refusal the embedded port returns as a sentinel, this one reconstructs from the response's RFC 9457 problem type, so the conformance suite can assert identical behaviour against both. A transport fault — unreachable server, unintelligible answer — is document.ErrUnavailable, which is never a statement about the document itself.

Reconstructing the document plane's errors from the wire: an entity tag becomes a revision, a body becomes a verified snapshot, and an RFC 9457 problem becomes the same sentinel the embedded port would have returned.

The client's transport mechanics: building one request, performing it, and reading its bounded body. The http.Response never escapes this file, so no caller can leak a connection by forgetting to close one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseURL

type BaseURL string

BaseURL is the sheet API root a client addresses.

type Client

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

Client is a document.Port over the sheet API.

func New

func New(base BaseURL, doer Doer) Client

New builds a client against base. A nil doer uses http.DefaultClient. The engine limits bound the local fold that verifies each accepted batch.

func NewWithLimits

func NewWithLimits(base BaseURL, doer Doer, limits tsvsheet.Limits) Client

NewWithLimits builds a client whose local verification fold is bounded by the given limits, which should match the server's so the two agree about what a batch may do.

func (Client) Apply

func (c Client) Apply(
	ctx context.Context,
	doc document.DocPath,
	batch tsvsheet.Edits,
	expect tsvsheet.RevisionHex,
) (document.Applied, error)

Apply folds an edits batch over the document at the expected revision.

func (Client) Delete

func (c Client) Delete(ctx context.Context, doc document.DocPath, expect tsvsheet.RevisionHex) error

Delete removes the document at the expected revision.

func (Client) Get

Get reads the document's canonical source and revision.

func (Client) Put

func (c Client) Put(
	ctx context.Context,
	doc document.DocPath,
	body []byte,
	expect document.Expect,
) (document.Snapshot, document.Created, error)

Put replaces or creates the document from a whole body.

type Doer

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer is the HTTP surface a client needs, injected so a caller supplies its own timeouts, transport, or test double.

Jump to

Keyboard shortcuts

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