replica

package
v1.17.5 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOK            = 0
	StatusClassNotFound = iota + 200
	StatusShardNotFound
	StatusNotFound
	StatusAlreadyExisted
	StatusNotReady
	StatusConflict = iota + 300
	StatusPreconditionFailed
	StatusReadOnly
)
View Source
const (
	// RequestKey is used to marshalling request IDs
	RequestKey = "request_id"
)

Variables

This section is empty.

Functions

func ValidateConfig

func ValidateConfig(class *models.Class) error

func ValidateConfigUpdate

func ValidateConfigUpdate(old, updated *models.Class, nodeCounter nodeCounter) error

Types

type Client

type Client interface {
	PutObject(ctx context.Context, host, index, shard, requestID string,
		obj *storobj.Object) (SimpleResponse, error)
	DeleteObject(ctx context.Context, host, index, shard, requestID string,
		id strfmt.UUID) (SimpleResponse, error)
	PutObjects(ctx context.Context, host, index, shard, requestID string,
		objs []*storobj.Object) (SimpleResponse, error)
	MergeObject(ctx context.Context, host, index, shard, requestID string,
		mergeDoc *objects.MergeDocument) (SimpleResponse, error)
	DeleteObjects(ctx context.Context, host, index, shard, requestID string,
		docIDs []uint64, dryRun bool) (SimpleResponse, error)
	AddReferences(ctx context.Context, host, index, shard, requestID string,
		refs []objects.BatchReference) (SimpleResponse, error)
	Commit(ctx context.Context, host, index, shard, requestID string, resp interface{}) error
	Abort(ctx context.Context, host, index, shard, requestID string) (SimpleResponse, error)
}

type ConsistencyLevel

type ConsistencyLevel string
const (
	One    ConsistencyLevel = "ONE"
	Quorum ConsistencyLevel = "QUORUM"
	All    ConsistencyLevel = "ALL"
)

type DeleteBatchResponse

type DeleteBatchResponse struct {
	Batch []UUID2Error `json:"batch,omitempty"`
}

DeleteBatchResponse represents the response returned by DeleteObjects

func (*DeleteBatchResponse) FirstError

func (r *DeleteBatchResponse) FirstError() error

FirstError returns the first found error

type Error

type Error struct {
	Code StatusCode `json:"code"`
	Msg  string     `json:"msg,omitempty"`
	Err  error      `json:"-"`
}

Error reports error happing during replication

func NewError

func NewError(code StatusCode, msg string) *Error

NewError create new replication error

func (*Error) Clone

func (e *Error) Clone() *Error

func (*Error) Empty

func (e *Error) Empty() bool

Empty checks whether e is an empty error which equivalent to e == nil

func (*Error) Error

func (e *Error) Error() string

func (*Error) IsStatusCode

func (e *Error) IsStatusCode(sc StatusCode) bool

func (*Error) Timeout

func (e *Error) Timeout() bool

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap underlying error

type Finder

type Finder struct {
	RClient // needed to commit and abort operation
	// contains filtered or unexported fields
}

Finder finds replicated objects

func NewFinder

func NewFinder(className string,
	stateGetter shardingState, nodeResolver nodeResolver,
	client RClient,
) *Finder

func (*Finder) FindOne

func (f *Finder) FindOne(ctx context.Context, l ConsistencyLevel, shard string,
	id strfmt.UUID, props search.SelectProperties, additional additional.Properties,
) (*storobj.Object, error)

FindOne finds one object which satisfies the giving consistency

func (*Finder) NodeObject

func (f *Finder) NodeObject(ctx context.Context, nodeName, shard string,
	id strfmt.UUID, props search.SelectProperties, additional additional.Properties,
) (*storobj.Object, error)

NodeObject gets object from a specific node. it is used mainly for debugging purposes

type RClient

type RClient interface {
	FindObject(ctx context.Context, host, index, shard string,
		id strfmt.UUID, props search.SelectProperties,
		additional additional.Properties) (*storobj.Object, error)
}

RClient is the client used to read from remote replicas

type RemoteReplicaIncoming

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

func (*RemoteReplicaIncoming) AbortReplication

func (rri *RemoteReplicaIncoming) AbortReplication(indexName,
	shardName, requestID string,
) interface{}

func (*RemoteReplicaIncoming) CommitReplication

func (rri *RemoteReplicaIncoming) CommitReplication(indexName,
	shardName, requestID string,
) interface{}

func (*RemoteReplicaIncoming) ReplicateDeletion

func (rri *RemoteReplicaIncoming) ReplicateDeletion(ctx context.Context, indexName,
	shardName, requestID string, uuid strfmt.UUID,
) SimpleResponse

func (*RemoteReplicaIncoming) ReplicateDeletions

func (rri *RemoteReplicaIncoming) ReplicateDeletions(ctx context.Context, indexName,
	shardName, requestID string, docIDs []uint64, dryRun bool,
) SimpleResponse

func (*RemoteReplicaIncoming) ReplicateObject

func (rri *RemoteReplicaIncoming) ReplicateObject(ctx context.Context, indexName,
	shardName, requestID string, object *storobj.Object,
) SimpleResponse

func (*RemoteReplicaIncoming) ReplicateObjects

func (rri *RemoteReplicaIncoming) ReplicateObjects(ctx context.Context, indexName,
	shardName, requestID string, objects []*storobj.Object,
) SimpleResponse

func (*RemoteReplicaIncoming) ReplicateReferences

func (rri *RemoteReplicaIncoming) ReplicateReferences(ctx context.Context, indexName,
	shardName, requestID string, refs []objects.BatchReference,
) SimpleResponse

func (*RemoteReplicaIncoming) ReplicateUpdate

func (rri *RemoteReplicaIncoming) ReplicateUpdate(ctx context.Context, indexName,
	shardName, requestID string, mergeDoc *objects.MergeDocument,
) SimpleResponse

type RemoteReplicaIncomingRepo

type RemoteReplicaIncomingRepo interface {
	ReplicateObject(ctx context.Context, indexName, shardName,
		requestID string, object *storobj.Object) SimpleResponse
	ReplicateObjects(ctx context.Context, indexName,
		shardName, requestID string, objects []*storobj.Object) SimpleResponse
	ReplicateUpdate(ctx context.Context, indexName,
		shardName, requestID string, mergeDoc *objects.MergeDocument) SimpleResponse
	ReplicateDeletion(ctx context.Context, indexName,
		shardName, requestID string, uuid strfmt.UUID) SimpleResponse
	ReplicateDeletions(ctx context.Context, indexName,
		shardName, requestID string, docIDs []uint64, dryRun bool) SimpleResponse
	ReplicateReferences(ctx context.Context, indexName,
		shardName, requestID string, refs []objects.BatchReference) SimpleResponse
	CommitReplication(indexName,
		shardName, requestID string) interface{}
	AbortReplication(indexName,
		shardName, requestID string) interface{}
}

type Replicator

type Replicator struct {
	*Finder
	// contains filtered or unexported fields
}

func NewReplicator

func NewReplicator(className string,
	stateGetter shardingState, nodeResolver nodeResolver,
	client Client, rClient RClient,
) *Replicator

func (*Replicator) AddReferences

func (r *Replicator) AddReferences(ctx context.Context, shard string,
	refs []objects.BatchReference,
) []error

func (*Replicator) DeleteObject

func (r *Replicator) DeleteObject(ctx context.Context, shard string,
	id strfmt.UUID,
) error

func (*Replicator) DeleteObjects

func (r *Replicator) DeleteObjects(ctx context.Context, shard string,
	docIDs []uint64, dryRun bool,
) []objects.BatchSimpleObject

func (*Replicator) MergeObject

func (r *Replicator) MergeObject(ctx context.Context, shard string,
	mergeDoc *objects.MergeDocument,
) error

func (*Replicator) PutObject

func (r *Replicator) PutObject(ctx context.Context, shard string,
	obj *storobj.Object,
) error

func (*Replicator) PutObjects

func (r *Replicator) PutObjects(ctx context.Context, shard string,
	objs []*storobj.Object,
) []error

type SimpleResponse

type SimpleResponse struct {
	Errors []Error `json:"errors,omitempty"`
}

func (*SimpleResponse) FirstError

func (r *SimpleResponse) FirstError() error

type StatusCode

type StatusCode int

type UUID2Error

type UUID2Error struct {
	UUID  string `json:"uuid,omitempty"`
	Error Error  `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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