rest

package
v0.0.0-...-0ca6a70 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package rest provides support for pushing witnessed checkpoints to a RESTful API.

Index

Constants

View Source
const (
	// HTTPCheckpointByWitness is the path of the URL to the latest checkpoint
	// for a given log by a given witness. This can take PUT requests to update
	// the latest checkpoint.
	//  * first position is for the logID (an alphanumeric string)
	//  * second position is the witness short name (alpha string)
	HTTPCheckpointByWitness = "/distributor/v0/logs/%s/byWitness/%s/checkpoint"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Distributor

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

Distributor distributes checkpoints to a REST API.

func NewDistributor

func NewDistributor(baseURL string, client *http.Client, logs []config.Log, witSigV note.Verifier, wit Witness) (*Distributor, error)

NewDistributor creates a new Distributor from the given configuration.

func (*Distributor) DistributeOnce

func (d *Distributor) DistributeOnce(ctx context.Context) error

DistributeOnce polls the witness for all logs and pushes the latest checkpoint to the RESTful distributor.

type Witness

type Witness interface {
	// GetLatestCheckpoint returns the latest checkpoint the witness holds for the given logID.
	// Must return os.ErrNotExists if the logID is known, but it has no checkpoint for that log.
	GetLatestCheckpoint(ctx context.Context, logID string) ([]byte, error)
}

Witness describes the operations the redistributor needs to interact with a witness.

Jump to

Keyboard shortcuts

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