fetch

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Overview

Package fetch contains a sidecar API client.

Package fetch contains a tracker API client.

Index

Constants

View Source
const (
	AdviceFetch        = Advice(iota) // download a snapshot
	AdviceNothingFound                // no snapshot available
	AdviceUpToDate                    // local snapshot is up-to-date or newer, don't download
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Advice added in v0.0.2

type Advice int

Advice indicates the recommended next action.

func ShouldFetchSnapshot added in v0.0.2

func ShouldFetchSnapshot(
	local []*types.SnapshotInfo,
	remote []types.SnapshotSource,
	minAge uint64,
	maxAge uint64,
) (minSlot uint64, advice Advice)

ShouldFetchSnapshot returns whether a new snapshot should be fetched.

If advice is AdviceFetch, `minSlot` indicates the lowest slot number at which fetch is useful.

type ProxyReaderFunc added in v0.0.2

type ProxyReaderFunc func(name string, size int64, rd io.Reader) io.ReadCloser

type SidecarClient

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

SidecarClient accesses the sidecar API.

func NewSidecarClient

func NewSidecarClient(sidecarURL string) *SidecarClient

func NewSidecarClientWithOpts added in v0.0.2

func NewSidecarClientWithOpts(sidecarURL string, opts SidecarClientOpts) *SidecarClient

func (*SidecarClient) DownloadSnapshotFile

func (c *SidecarClient) DownloadSnapshotFile(ctx context.Context, destDir string, name string) error

DownloadSnapshotFile downloads a snapshot to a file in the local file system.

func (*SidecarClient) ListSnapshots

func (c *SidecarClient) ListSnapshots(ctx context.Context) (infos []*types.SnapshotInfo, err error)

func (*SidecarClient) StreamSnapshot added in v0.0.2

func (c *SidecarClient) StreamSnapshot(ctx context.Context, name string) (res *http.Response, err error)

StreamSnapshot starts a download of a snapshot file. The returned response is guaranteed to have a valid ContentLength. The caller has the responsibility to close the response body even if the error is not nil.

type SidecarClientOpts added in v0.0.2

type SidecarClientOpts struct {
	Resty           *resty.Client
	Log             *zap.Logger
	ProxyReaderFunc ProxyReaderFunc
}

type TrackerClient

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

TrackerClient accesses the tracker API.

func NewTrackerClient

func NewTrackerClient(trackerURL string) *TrackerClient

func NewTrackerClientWithResty

func NewTrackerClientWithResty(client *resty.Client) *TrackerClient

func (*TrackerClient) GetBestSnapshots

func (c *TrackerClient) GetBestSnapshots(ctx context.Context, count int) (sources []types.SnapshotSource, err error)

Jump to

Keyboard shortcuts

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