Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReplicationID ¶ added in v0.5.14
TODO: refactor Service interface to use ReplicationID instead of separate user, bucket, from, to, toBucket arguments
func ReplicationIDFromStr ¶ added in v0.5.14
func ReplicationIDFromStr(s string) (ReplicationID, error)
func (ReplicationID) RoutingKey ¶ added in v0.5.14
func (r ReplicationID) RoutingKey() string
func (ReplicationID) StatusKey ¶ added in v0.5.14
func (r ReplicationID) StatusKey() string
func (ReplicationID) String ¶ added in v0.5.14
func (r ReplicationID) String() string
func (ReplicationID) SwitchHistoryKey ¶ added in v0.5.14
func (r ReplicationID) SwitchHistoryKey() string
func (ReplicationID) SwitchKey ¶ added in v0.5.14
func (r ReplicationID) SwitchKey() string
func (ReplicationID) Validate ¶ added in v0.5.14
func (r ReplicationID) Validate() error
type ReplicationPolicies ¶
type ReplicationPolicies struct {
From string
To map[ReplicationPolicyDest]tasks.Priority
}
type ReplicationPolicyDest ¶ added in v0.5.13
type ReplicationPolicyDest string
func (ReplicationPolicyDest) Parse ¶ added in v0.5.13
func (d ReplicationPolicyDest) Parse() (storage string, bucket *string)
type ReplicationPolicyStatus ¶
type ReplicationPolicyStatus struct {
CreatedAt time.Time `redis:"created_at"`
IsPaused bool `redis:"paused"`
IsArchived bool `redis:"archived"`
InitObjListed int64 `redis:"obj_listed"`
InitObjDone int64 `redis:"obj_done"`
InitBytesListed int64 `redis:"bytes_listed"`
InitBytesDone int64 `redis:"bytes_done"`
Events int64 `redis:"events"`
EventsDone int64 `redis:"events_done"`
AgentURL string `redis:"agent_url,omitempty"`
InitDoneAt *time.Time `redis:"init_done_at,omitempty"`
LastEmittedAt *time.Time `redis:"last_emitted_at,omitempty"`
LastProcessedAt *time.Time `redis:"last_processed_at,omitempty"`
ArchivedAt *time.Time `redis:"archived_at,omitempty"`
ListingStarted bool `redis:"listing_started"`
HasSwitch bool `redis:"-"`
}
func (*ReplicationPolicyStatus) InitDone ¶ added in v0.5.14
func (r *ReplicationPolicyStatus) InitDone() bool
type Service ¶
type Service interface {
// GetRoutingPolicy returns destination storage name.
// Errors:
// dom.ErrRoutingBlock - if access to bucket should be blocked because bucket is used as replication destination.
// dom.ErrNotFound - if replication is not configured.
GetRoutingPolicy(ctx context.Context, user, bucket string) (string, error)
AddRoutingBlock(ctx context.Context, storage, bucket string) error
DeleteRoutingBlock(ctx context.Context, storage, bucket string) error
GetUserRoutingPolicy(ctx context.Context, user string) (string, error)
AddUserRoutingPolicy(ctx context.Context, user, toStorage string) error
// Upsert downtime replication switch. If switch already exists and not in progress, it will be updated.
SetDowntimeReplicationSwitch(ctx context.Context, replID ReplicationID, opts *SwitchDowntimeOpts) error
// Change downtime replication switch status. Makes required adjustments to routing and replication policies.
// According to switch status and configured options.
UpdateDowntimeSwitchStatus(ctx context.Context, replID ReplicationID, newStatus SwitchStatus, description string, startedAt, doneAt *time.Time) error
// Creates new zero downtime replication switch.
AddZeroDowntimeReplicationSwitch(ctx context.Context, replID ReplicationID, opts *SwitchZeroDowntimeOpts) error
// Completes zero downtime replication switch.
CompleteZeroDowntimeReplicationSwitch(ctx context.Context, replID ReplicationID) error
// Deletes any replication switch if exists and reverts routing policy if switch was not done.
DeleteReplicationSwitch(ctx context.Context, replID ReplicationID) error
// Returns replication switch config and status information.
GetReplicationSwitchInfo(ctx context.Context, replID ReplicationID) (SwitchInfo, error)
ListReplicationSwitchInfo(ctx context.Context) ([]SwitchInfo, error)
// GetInProgressZeroDowntimeSwitchInfo shortcut method for chorus proxy to get required information
// to adjust route only when zero downtime switch is in progress.
GetInProgressZeroDowntimeSwitchInfo(ctx context.Context, user, bucket string) (ZeroDowntimeSwitchInProgressInfo, error)
GetBucketReplicationPolicies(ctx context.Context, user, bucket string) (ReplicationPolicies, error)
GetUserReplicationPolicies(ctx context.Context, user string) (ReplicationPolicies, error)
AddUserReplicationPolicy(ctx context.Context, user string, from string, to string, priority tasks.Priority) error
DeleteUserReplication(ctx context.Context, user string, from string, to string) error
AddBucketReplicationPolicy(ctx context.Context, user, bucket, from string, to string, toBucket *string, priority tasks.Priority, agentURL *string) error
GetReplicationPolicyInfo(ctx context.Context, user, bucket, from, to string, toBucket *string) (ReplicationPolicyStatus, error)
ListReplicationPolicyInfo(ctx context.Context) ([]ReplicationPolicyStatusExtended, error)
IsReplicationPolicyExists(ctx context.Context, user, bucket, from, to string, toBucket *string) (bool, error)
IsReplicationPolicyPaused(ctx context.Context, user, bucket, from, to string, toBucket *string) (bool, error)
IncReplInitObjListed(ctx context.Context, user, bucket, from, to string, toBucket *string, bytes int64, eventTime time.Time) error
IncReplInitObjDone(ctx context.Context, user, bucket, from, to string, toBucket *string, bytes int64, eventTime time.Time) error
ObjListStarted(ctx context.Context, user, bucket, from, to string, toBucket *string) error
IncReplEvents(ctx context.Context, user, bucket, from, to string, toBucket *string, eventTime time.Time) error
IncReplEventsDone(ctx context.Context, user, bucket, from, to string, toBucket *string, eventTime time.Time) error
PauseReplication(ctx context.Context, user, bucket, from string, to string, toBucket *string) error
ResumeReplication(ctx context.Context, user, bucket, from string, to string, toBucket *string) error
DeleteReplication(ctx context.Context, user, bucket, from string, to string, toBucket *string) error
// Archive replication. Will stop generating new events for this replication.
// Existing events will be processed and replication status metadata will be kept.
ArchiveReplication(ctx context.Context, replID ReplicationID) error
DeleteBucketReplicationsByUser(ctx context.Context, user, from string, to string) ([]string, error)
// contains filtered or unexported methods
}
// go:generate go tool mockery --name=Service --filename=service_mock.go --inpackage --structname=MockService
func NewService ¶
func NewService(client redis.UniversalClient) Service
type SwitchDowntimeOpts ¶ added in v0.5.14
type SwitchDowntimeOpts struct {
StartOnInitDone bool `redis:"onInitDone"`
Cron *string `redis:"cron,omitempty"`
StartAt *time.Time `redis:"startAt,omitempty"`
MaxDuration time.Duration `redis:"maxDuration,omitempty"`
MaxEventLag *uint32 `redis:"maxEventLag,omitempty"`
SkipBucketCheck bool `redis:"skipBucketCheck,omitempty"`
ContinueReplication bool `redis:"continueReplication,omitempty"`
}
func (*SwitchDowntimeOpts) GetCron ¶ added in v0.5.14
func (w *SwitchDowntimeOpts) GetCron() (string, bool)
func (*SwitchDowntimeOpts) GetMaxDuration ¶ added in v0.5.14
func (w *SwitchDowntimeOpts) GetMaxDuration() (time.Duration, bool)
func (*SwitchDowntimeOpts) GetMaxEventLag ¶ added in v0.5.14
func (w *SwitchDowntimeOpts) GetMaxEventLag() (uint32, bool)
func (*SwitchDowntimeOpts) GetStartAt ¶ added in v0.5.14
func (w *SwitchDowntimeOpts) GetStartAt() (time.Time, bool)
type SwitchInfo ¶ added in v0.5.14
type SwitchInfo struct {
// Options for downtime switch
SwitchDowntimeOpts
// Options for zero downtime switch
SwitchZeroDowntimeOpts
// Task priority of replication policy of this switch
ReplicationPriority uint8 `redis:"replPriority,omitempty"`
// ID of replication policy of this switch
ReplicationIDStr string `redis:"replicationID"`
// Time of switch creation
CreatedAt time.Time `redis:"createdAt"`
// Last status of switch
LastStatus SwitchStatus `redis:"lastStatus,omitempty"`
// Time of last switch was in progress
LastStartedAt *time.Time `redis:"startedAt,omitempty"`
// Time of last switch was done
DoneAt *time.Time `redis:"doneAt,omitempty"`
// History of switch status changes
History []string `redis:"-"`
}
Contains all information about replication switch including its configuration and current status.
func (*SwitchInfo) GetLastStartAt ¶ added in v0.5.14
func (s *SwitchInfo) GetLastStartAt() (time.Time, bool)
func (*SwitchInfo) IsTimeToStart ¶ added in v0.5.14
func (s *SwitchInfo) IsTimeToStart() (bool, error)
func (*SwitchInfo) IsZeroDowntime ¶ added in v0.5.14
func (s *SwitchInfo) IsZeroDowntime() bool
func (*SwitchInfo) ReplicationID ¶ added in v0.5.14
func (s *SwitchInfo) ReplicationID() (ReplicationID, error)
type SwitchStatus ¶ added in v0.5.2
type SwitchStatus string
const ( // StatusNotStarted means that switch donwntime is not started yet // Relevant only for downtime switches StatusNotStarted SwitchStatus = "not_started" // StatusInProgress means that downtime is started, bucket is blocked until task queue is drained or timeout StatusInProgress SwitchStatus = "in_progress" // StatusCheckInProgress means that task queue is drained and bucket is blocked until src and dst bucket contents will be checked // Relevant only for downtime switches StatusCheckInProgress SwitchStatus = "check_in_progress" // StatusDone means that switch is successfully finished and data is routed to new bucket. StatusDone SwitchStatus = "done" // StatusError means that switch was aborted due to error // Relevant only for downtime switches StatusError SwitchStatus = "error" // StatusSkipped means that switch attempt was skipped because conditions were not met // Relevant only for downtime switches StatusSkipped SwitchStatus = "skipped" )
func (SwitchStatus) MarshalBinary ¶ added in v0.5.14
func (s SwitchStatus) MarshalBinary() (data []byte, err error)
func (*SwitchStatus) UnmarshalBinary ¶ added in v0.5.14
func (s *SwitchStatus) UnmarshalBinary(data []byte) error
type SwitchZeroDowntimeOpts ¶ added in v0.5.14
type ZeroDowntimeSwitchInProgressInfo ¶ added in v0.5.14
type ZeroDowntimeSwitchInProgressInfo struct {
ReplicationIDStr string `redis:"replicationID"`
Status SwitchStatus `redis:"lastStatus"`
MultipartTTL time.Duration `redis:"multipartTTL"`
ReplicationPriority uint8 `redis:"replPriority,omitempty"`
}
Reduced replication switch info for in progress zero downtime switch. Subset of SwitchInfo fields. Used by proxy to route requests to correct bucket during zero downtime switch.
func (*ZeroDowntimeSwitchInProgressInfo) ReplicationID ¶ added in v0.5.14
func (s *ZeroDowntimeSwitchInProgressInfo) ReplicationID() (ReplicationID, error)
Click to show internal directories.
Click to hide internal directories.