storages

package
v0.0.0-...-d88ec87 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 26 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

type ClusterStorage

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

ClusterStorage is basic cluster storage interface

type ConsistencyShardClient

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

ConsistencyShardClient is a shard that guarantees consistency based on the defined provided consistency level

func (*ConsistencyShardClient) Backends

func (consistencyShard *ConsistencyShardClient) Backends() []*StorageClient

Backends returns the backends of a shard

func (*ConsistencyShardClient) Name

func (consistencyShard *ConsistencyShardClient) Name() string

Name returns the name of the shard

func (*ConsistencyShardClient) RoundTrip

func (consistencyShard *ConsistencyShardClient) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip performs the request and also records the request if the consistency level requires so

type Factory

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

Factory creates storages

func NewStoragesFactory

func NewStoragesFactory(transport http.RoundTripper, watchdogConfig *watchdogConfig.WatchdogConfig,
	watchdog watchdog.ConsistencyWatchdog, watchdogRequestFactory watchdog.ConsistencyRecordFactory) *Factory

NewStoragesFactory creates StoragesFactory

func (*Factory) InitStorages

func (factory *Factory) InitStorages(clustersConf config.ShardsMap, storagesMap config.StoragesMap, ignoredHeaders map[string]bool) (ClusterStorage, error)

InitStorages setups storages

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 NamedShardClient

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

NamedShardClient interface

func NewConsistentShard

func NewConsistentShard(shardClient NamedShardClient,
	consistencyWatchdgo watchdog.ConsistencyWatchdog,
	recordFactory watchdog.ConsistencyRecordFactory,
	versionHeaderName string) NamedShardClient

NewConsistentShard wraps the provided shard with ConsistencyShardClient to ensure consistency

func NewShardAuthenticator

func NewShardAuthenticator(shardClient NamedShardClient, ignoredCanonicalizedHeaders map[string]bool) NamedShardClient

NewShardAuthenticator creates an instance of ShardAuthenticator

type ObjectResponsePicker

type ObjectResponsePicker struct {
	BasePicker
}

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

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) *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 ShardAuthenticator

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

ShardAuthenticator is a delegating NamedSharedClient that checks the requests authorization

func (*ShardAuthenticator) Backends

func (shardAuth *ShardAuthenticator) Backends() []*StorageClient

Backends returns the backends of a shard

func (*ShardAuthenticator) Name

func (shardAuth *ShardAuthenticator) Name() string

Name returns then of the shard

func (*ShardAuthenticator) RoundTrip

func (shardAuth *ShardAuthenticator) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip first ensures that client is authorized to access the shard and the delegates the request to shard client

type ShardClient

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

ShardClient stores information about cluster backends

func (*ShardClient) Backends

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

Backends get http.RoundTripper slice

func (*ShardClient) Name

func (shardClient *ShardClient) Name() string

Name get Cluster name

func (*ShardClient) RoundTrip

func (shardClient *ShardClient) RoundTrip(request *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 (*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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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