client

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: Apache-2.0, BSD-3-Clause, MPL-2.0 Imports: 17 Imported by: 0

README

Chunky Client

Chunky client is a client for interacting with our Chunky object storage server.

Usage

go get -u github.com/offloaded/chunky-client

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtai one at https://mozilla.org/MPL/2.0/.

Documentation

Index

Constants

View Source
const (
	DefaultChunkSize      = 1000000
	DefaultNetworkThreads = 4
	DefaultRetryAttempts  = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChunkClient

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

ChunkClient is a client for fetching and pushing chunks.

func NewChunkClient

func NewChunkClient(httpClient *http.Client, url string, chunkCache *cache.Cache) *ChunkClient

NewChunkClient creates a new chunk client.

func (*ChunkClient) Fetch

func (c *ChunkClient) Fetch(ctx context.Context, hash [contenthash.Size]byte) ([]byte, error)

Fetch retrieves a chunk from the server.

func (*ChunkClient) Push

func (c *ChunkClient) Push(ctx context.Context, hash [contenthash.Size]byte, data []byte) error

Push pushes a chunk to the server.

type Client

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

Client is an object storage client.

func NewClient

func NewClient(grpcObjectClient pb.ObjectClient, chunkClient *ChunkClient) *Client

NewClient creates a new object storage client.

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, hash [contenthash.Size]byte, opts FetchOpts) (io.ReadCloser, error)

Fetch an object from a remote server.

func (*Client) Push

func (c *Client) Push(ctx context.Context, src io.Reader, opts PushOpts) (*pb.ObjectManifest, error)

Push an object to a remote server.

type FetchOpts

type FetchOpts struct {
	// NetworkThreads is the number of parallel threads to use for fetching chunks.
	NetworkThreads int
	// RetryAttempts is the number of times to retry fetching a chunk.
	RetryAttempts uint
}

FetchOpts is used to configure the behaviour of fetching an object.

type PushOpts

type PushOpts struct {
	// ChunkSize is the nominal size of each chunk.
	ChunkSize int64
	// NetworkThreads is the number of parallel threads to use for pushing chunks.
	NetworkThreads int
	// RetryAttempts is the number of times to retry pushing a chunk.
	RetryAttempts uint
}

PushOpts is used to configure the behaviour of pushing an object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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