restclient

package
v0.0.0-...-6f34b33 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 11 Imported by: 0

README

Coordinate REST Client

This package defines a REST client for the Coordinate system. It matches the REST server in the ../restserver package.

Usage

Run a ../cmd/coordinated process with an HTTP server, e.g.

go install github.com/diffeo/go-coordinate/cmd/coordinated
coordinated -backend memory -http :5980

Then run your client code pointing at that service. To run a coordinated proxy, for instance,

coordinated -backend http://localhost:5980/ -http :5981

Limitations

In most cases names of objects are embedded directly into URLs. If they are not printable, the URL scheme can pass base64-encoded keys as well; see the [../restserver/doc.go](REST API documentation) for details.

There is no single unique identifier for attempts. The URL scheme assumes that at most one attempt will be created for a specific work unit, for a specific worker, in a single millisecond. This is not a hard guarantee but it would be unusual for it to break: it either implies duplicate attempts are being issued, or attempts are being forced for specific work units, or an attempt is requested, marked retryable, and requested again all within 1 ms.

Documentation

Overview

Package restclient provides a Coordinate-compatible HTTP REST client that talks to the matching server in the "restserver" package.

The server in github.com/diffeo/go-coordinate/cmd/coordinated can run a compatible REST server. Call New() with the base URL of that service; for instance,

c, err := restclient.New("http://localhost:5980/")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(baseURL string) (coordinate.Coordinate, error)

New creates a new Coordinate interface that speaks to an external REST server.

Types

type ErrorHTTP

type ErrorHTTP struct {
	// Response holds a pointer to the failing HTTP response.
	Response *http.Response

	// Body holds the contents of the message body, presumed to
	// be text.
	Body string
}

ErrorHTTP is a catch-all error for non-successes returned from the REST endpoint.

func (ErrorHTTP) Error

func (e ErrorHTTP) Error() string

Jump to

Keyboard shortcuts

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