reflector

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultPort is the port the reflector server listens on if not passed in.
	DefaultPort = 5566
	// DefaultTimeout is the default timeout to read or write the next message
	DefaultTimeout = 5 * time.Second
)

Variables

View Source
var ErrBlobExists = errors.Base("blob exists on server")

ErrBlobExists is a default error for when a blob already exists on the reflector server.

View Source
var ErrBlobTooBig = errors.Base("blob must be at most %d bytes", maxBlobSize)

Functions

func BlobHash added in v1.0.2

func BlobHash(blob []byte) string

BlobHash returns the sha512 hash hex encoded string of the blob byte slice.

func IsValidJSON added in v1.1.0

func IsValidJSON(b []byte) bool

Types

type Client

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

Client is an instance of a client connected to a server.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection with the client.

func (*Client) Connect

func (c *Client) Connect(address string) error

Connect connects to a specific clients and errors if it cannot be contacted.

func (*Client) SendBlob

func (c *Client) SendBlob(blob stream.Blob) error

SendBlob sends a send blob request to the client.

type Server

type Server struct {
	Timeout time.Duration // timeout to read or write next message

	EnableBlocklist bool // if true, blocklist checking and blob deletion will be enabled
	// contains filtered or unexported fields
}

Server is and instance of the reflector server. It houses the blob store and listener.

func NewServer

func NewServer(store store.BlobStore) *Server

NewServer returns an initialized reflector server pointer.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown shuts down the reflector server gracefully.

func (*Server) Start

func (s *Server) Start(address string) error

Start starts the server to handle connections.

type Summary added in v1.1.0

type Summary struct {
	Total, AlreadyStored, Sd, Blob, Err int
}

type Uploader added in v1.1.0

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

func NewUploader added in v1.1.0

func NewUploader(db *db.SQL, store *store.DBBackedStore, workers int, skipExistsCheck bool) *Uploader

func (*Uploader) GetSummary added in v1.1.0

func (u *Uploader) GetSummary() Summary

func (*Uploader) Stop added in v1.1.0

func (u *Uploader) Stop()

func (*Uploader) Upload added in v1.1.0

func (u *Uploader) Upload(dirOrFilePath string) error

Jump to

Keyboard shortcuts

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