api

package
Version: v0.0.0-...-197f44b Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default max connection count of each server.
	DefaultMaxConnectionsPerServer = 100
)

Variables

View Source
var NoStorageServerErr = errors.New("no storage available")

Functions

func FilterInstanceByInstanceId

func FilterInstanceByInstanceId(instanceId string) *common.Instance

func FilterInstances

func FilterInstances(role common.Role) *list.List

func FilterUploadableInstances

func FilterUploadableInstances() *list.List

FilterReadonlyInstances gets readonly storage instance.

func NewClient

func NewClient() *clientAPIImpl

NewClient creates a new APIClient.

Types

type ClientAPI

type ClientAPI interface {
	// SetConfig sets or refresh client server config.
	SetConfig(config *Config)

	// Upload uploads file to specific group server.
	//
	// If no group provided, it will upload file to a random server.
	Upload(src io.Reader, length int64, group string, isPrivate bool) (*common.UploadResult, error)

	// Download downloads a file from server.
	//
	// Return error can be common.NoStorageServerErr if there is no server available
	//
	// or common.NotFoundErr if the file cannot be found on the servers.
	Download(fileId string, offset int64, length int64,
		handler func(body io.Reader, bodyLength int64) error) error

	DownloadFrom(fileId string, offset int64, length int64, server *common.Server,
		handler func(body io.Reader, bodyLength int64) error) error

	// Query queries file's information by fileId.
	//
	// Parameter `fileId` must be the pattern of common.FILE_ID_PATTERN
	Query(fileId string) (*common.FileInfo, error)

	// SyncInstances synchronizes instances from specific tracker server.
	SyncInstances(server *common.Server) (map[string]*common.Instance, error)

	// PushBinlog pushes binlog to tracker server.
	PushBinlog(server *common.Server, binlogs []common.BingLogDTO) error

	// SyncBinlog synchronizes binlogs from other storage servers.
	SyncBinlog(server *common.Server, clientState *common.BinlogQueryDTO) (*common.BinlogQueryResultDTO, error)

	// SelectStorageServer selects proper storage server.
	SelectStorageServer(group string, uploadable bool, exclude *list.List) *common.StorageServer
}

ClientAPI is godfs APIClient interface.

type Config

type Config struct {
	MaxConnectionsPerServer uint                    // limit max connection for each server
	TrackerServers          []*common.Server        // tracker servers
	SynchronizeOnce         bool                    // synchronize with each tracker server only once
	SynchronizeOnceCallback chan int                // attached with `SynchronizeOnce`, for noticing client cli that whether all server is synced.
	StaticStorageServers    []*common.StorageServer // storage servers
}

Config is the APIClient config

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL