storages

package
v0.0.0-...-e6f4ba9 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrImpossibleMultipart = errors.New("Can't handle multi upload")

ErrImpossibleMultipart is issued if there is no viable backend to store file

View Source
var ErrReplicationIndicator = errors.New("Replication required")

ErrReplicationIndicator signals backends where object has to be replicated

View Source
var ErrRequestCanceled = fmt.Errorf("Request canceled")

ErrRequestCanceled is returned if request was canceled

Functions

This section is empty.

Types

type BackendResponse

type BackendResponse = backend.Response

BackendResponse is alias of storage.types.BackendResponse

type BasePicker

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

BasePicker contains common methods of pickers

func (*BasePicker) SendSyncLog

func (bp *BasePicker) SendSyncLog(*SyncSender)

SendSyncLog implements picker interface

type Cluster

type Cluster struct {
	MethodSet set.Set
	// contains filtered or unexported fields
}

Cluster stores information about cluster backends

func (*Cluster) Backends

func (c *Cluster) Backends() []*Backend

Backends get http.RoundTripper slice

func (*Cluster) Name

func (c *Cluster) Name() string

Name get Cluster name

func (*Cluster) RoundTrip

func (c *Cluster) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper interface

type ClusterStorage

type ClusterStorage interface {
	GetShard(name string) (NamedShardClient, error)
	MergeShards(name string, clusters ...NamedShardClient) NamedShardClient
}

ClusterStorage is basic cluster storage interface

type MultiPartRoundTripper

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

MultiPartRoundTripper handles the multipart upload. If multipart upload is detected, it delegates the request to the backend selected using the active backends hash ring, otherwise the cluster round tripper is used to handle the operation in standard fashion

func (MultiPartRoundTripper) Cancel

func (multiPartRoundTripper MultiPartRoundTripper) Cancel() error

Cancel Client interface

func (*MultiPartRoundTripper) Do

func (multiPartRoundTripper *MultiPartRoundTripper) Do(request *http.Request) <-chan BackendResponse

Do performs backend request

type NamedCluster

type NamedCluster interface {
	http.RoundTripper
	Name() string
	Backends() []*Backend
}

NamedCluster interface

type NamedShardClient

type NamedShardClient interface {
	http.RoundTripper
	Name() string
	Backends() []*StorageClient
}

NamedShardClient interface

type ObjectResponsePicker

type ObjectResponsePicker struct {
	BasePicker
	// contains filtered or unexported fields
}

ObjectResponsePicker chooses first successful or one of failure response from chan of `BackendResponse`s

func (*ObjectResponsePicker) Pick

func (orp *ObjectResponsePicker) Pick() (*http.Response, error)

Pick returns first successful response, discards others

func (*ObjectResponsePicker) SendSyncLog

func (orp *ObjectResponsePicker) SendSyncLog(syncLog *SyncSender)

SendSyncLog implements picker interface

type ReplicationClient

type ReplicationClient struct {
	Backends []*backend.Backend
	// contains filtered or unexported fields
}

ReplicationClient is multiple endpoints client

func (*ReplicationClient) Cancel

func (rc *ReplicationClient) Cancel() error

Cancel requests in progress

func (*ReplicationClient) Do

func (rc *ReplicationClient) Do(request *http.Request) <-chan BackendResponse

Do send request to all given backends

type RequestDispatcher

type RequestDispatcher struct {
	Backends []*backend.Backend
	// contains filtered or unexported fields
}

RequestDispatcher passes requests and responses to matching replicators and response pickers

func NewRequestDispatcher

func NewRequestDispatcher(backends []*backend.Backend, syncLog *SyncSender) *RequestDispatcher

NewRequestDispatcher creates RequestDispatcher instance

func (*RequestDispatcher) Dispatch

func (rd *RequestDispatcher) Dispatch(request *http.Request) (*http.Response, error)

Dispatch creates and calls replicators and response pickers

type ShardClient

type ShardClient struct {
	MethodSet set.Set
	// contains filtered or unexported fields
}

ShardClient stores information about cluster backends

func (*ShardClient) Backends

func (c *ShardClient) Backends() []*StorageClient

Backends get http.RoundTripper slice

func (*ShardClient) Name

func (c *ShardClient) Name() string

Name get Cluster name

func (*ShardClient) RoundTrip

func (c *ShardClient) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper interface

type StorageClient

type StorageClient = backend.Backend

StorageClient is alias of storage.types.StorageClient

type Storages

type Storages struct {
	ShardClients map[string]NamedShardClient
	Backends     map[string]*StorageClient
	// contains filtered or unexported fields
}

Storages config

func InitStorages

func InitStorages(transport http.RoundTripper, clustersConf config.ShardsMap,
	storagesMap config.StoragesMap, syncLog *SyncSender) (*Storages, error)

InitStorages setups storages

func (*Storages) GetShard

func (st *Storages) GetShard(name string) (NamedShardClient, error)

GetShard gets cluster by name or nil if cluster with given name was not found

func (*Storages) MergeShards

func (st *Storages) MergeShards(name string, clusters ...NamedShardClient) NamedShardClient

MergeShards extends Clusters list of Storages by cluster made of joined clusters backends and returns it. If cluster of given name is already defined returns previously defined cluster instead.

type SyncSender

type SyncSender struct {
	AllowedMethods map[string]struct{}
	SyncLog        log.Logger
}

SyncSender filters and writes inconsistencies to synclog

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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