server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChunkerParams

type ChunkerParams struct {
	MinChunkSize  uint `json:"min_chunk_size"`
	AvgChunkSize  uint `json:"avg_chunk_size"`
	MaxChunkSize  uint `json:"max_chunk_size"`
	Normalization uint `json:"normalization"`
}

ChunkerParams store the parameters that should be used to chunk files for a server.

type Config

type Config struct {
	// Bucket is the bucket the server saves files to.
	Bucket string

	// VersioningEnabled, if set to true, turns on file versioning.
	VersioningEnabled bool

	// MaxChunkSize is the maximum permitted size of a chunk in bytes.
	MaxChunkSize uint64

	// MaxPackfileSize is the maximum permitted size of a packfile in bytes.
	MaxPackfileSize uint64

	DownloadTimeout time.Duration

	Params ChunkerParams
}

Config stores the configuration for the Server.

type Server

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

Server implements the Api interface specified in upload.proto.

func New

func New(db *db.Adapter, s store.Store, cfg Config) *Server

New creates a new Server.

func (*Server) ChunksExist

func (srv *Server) ChunksExist(ctx context.Context, req *pb.ChunksExistRequest) (*pb.ChunksExistResponse, error)

ChunksExist checks if a list of chunks already exist in the store. The response contains a boolean for each chunk in the request.

func (*Server) Copy

func (srv *Server) Copy(ctx context.Context, req *pb.CopyRequest) (*pb.FileID, error)

Copy makes a copy of a file and returns its ID. Returns a NotFound error if the file does not exist.

func (*Server) CreateFile

func (srv *Server) CreateFile(ctx context.Context, file *pb.File) (*pb.FileID, error)

CreateFile creates a new file. Returns an error if any chunk referenced by the file does not exist.

func (*Server) Delete

func (srv *Server) Delete(ctx context.Context, fileID *pb.FileID) (*pb.Empty, error)

Delete removes a file. Returns a NotFound error if the files does not exist.

func (*Server) Download

func (srv *Server) Download(ctx context.Context, id *pb.FileID) (*pb.DownloadResponse, error)

Download returns a collection of URLs to download the data for a file. Each URL contains data for a contiguous section of the file.

func (*Server) GetChunkerParams

func (srv *Server) GetChunkerParams(ctx context.Context, _ *pb.Empty) (*pb.ChunkerParams, error)

GetChunkerParams returns the chunking parameters that clients should use to chunk files for this server.

func (*Server) Head

func (srv *Server) Head(ctx context.Context, req *pb.HeadRequest) (*pb.HeadResponse, error)

Head returns all versions of a file with a given name. The parameters Limit, NextPageToken and Ascending have the same meaning as in the List method.

func (*Server) List

func (srv *Server) List(ctx context.Context, req *pb.ListRequest) (*pb.ListResponse, error)

List returns all versions of files with a given prefix. The response NextPageToken can be used to retrieve the next page of results, unless it has the value -1, in which case no further pages exist. The parameter Limit sets the maximum number of results per page and must be provided. The parameter Exclude may be provided as a glob pattern to exclude files from the response. If Exclude is set, the Include parameter may also be provided to force inclusion of any files excluded by the Exclude pattern. Results are returned in reverse-chronological order of file created date by default. Ascending may be set to true to reverse the order.

func (*Server) PackfileUploadHandler

func (srv *Server) PackfileUploadHandler(w http.ResponseWriter, req *http.Request)

PackfileUploadHandler accepts a Packfile from a client and saves it to the store.

func (*Server) ServerStats

func (srv *Server) ServerStats(ctx context.Context, _ *pb.Empty) (*pb.Stats, error)

ServerStats returns summary statistics for the server.

func (*Server) SetLogger

func (srv *Server) SetLogger(logger zerolog.Logger)

SetLogger sets the logger for the server.

func (*Server) StartVacuum

func (srv *Server) StartVacuum(ctx context.Context, _ *pb.Empty) (*pb.VacuumID, error)

StartVacuum starts a new vacuum process. Returns a twirp.Unavailable error if a vacuum process is already running. Returns an ID for the vacuum which can be used to check the status of the vacuum.

func (*Server) VacuumStatus

func (srv *Server) VacuumStatus(ctx context.Context, id *pb.VacuumID) (*pb.Vacuum, error)

VacuumStatus returns the status of a vacuum process with a given ID. Returns a twirp.NotFound error if the vacuum does not exist.

Jump to

Keyboard shortcuts

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