Documentation ¶
Index ¶
- func AddCluster(config *model.Config, name string, newCluster *model.AerospikeCluster) error
- func AddPolicy(config *model.Config, name string, newPolicy *model.BackupPolicy) error
- func AddRoutine(config *model.Config, name string, newRoutine *model.BackupRoutine) error
- func AddStorage(config *model.Config, name string, newStorage *model.Storage) error
- func BuildBackupBackends(config *model.Config) map[string]*BackupBackend
- func DeleteCluster(config *model.Config, name string) error
- func DeletePolicy(config *model.Config, name string) error
- func DeleteRoutine(config *model.Config, name string) error
- func DeleteStorage(config *model.Config, name string) error
- func NewAdHocFullBackupJobForRoutine(name string) *quartz.JobDetail
- func NewRunningJob(startTime time.Time, done, total uint64) *model.RunningJob
- func RestoreJobStatus(job *jobInfo) *model.RestoreJobStatus
- func ScheduleBackup(ctx context.Context, config *model.Config, handlers BackupHandlerHolder) (quartz.Scheduler, error)
- func UpdateCluster(config *model.Config, name string, updatedCluster *model.AerospikeCluster) error
- func UpdatePolicy(config *model.Config, name string, updatedPolicy *model.BackupPolicy) error
- func UpdateRoutine(config *model.Config, name string, updatedRoutine *model.BackupRoutine) error
- func UpdateStorage(config *model.Config, name string, updatedStorage *model.Storage) error
- type AerospikeClientFactory
- type BackendHolderImpl
- type BackendsHolder
- type Backup
- type BackupBackend
- func (b *BackupBackend) FindIncrementalBackupsForNamespace(bounds *model.TimeBounds, namespace string) ([]model.BackupDetails, error)
- func (b *BackupBackend) FindLastFullBackup(toTime time.Time) ([]model.BackupDetails, error)
- func (b *BackupBackend) FullBackupInProgress() *atomic.Bool
- func (b *BackupBackend) FullBackupList(timebounds *model.TimeBounds) ([]model.BackupDetails, error)
- func (b *BackupBackend) IncrementalBackupList(timebounds *model.TimeBounds) ([]model.BackupDetails, error)
- func (b *BackupBackend) ReadClusterConfiguration(path string) ([]byte, error)
- type BackupGo
- type BackupHandler
- type BackupHandlerHolder
- type BackupListReader
- type BackupRoutineHandler
- type ClientManager
- type ClientManagerImpl
- type ConfigManagerBuilder
- type ConfigurationManager
- type DefaultClientFactory
- type FileConfigurationManager
- type FileReader
- type HTTPConfigurationManager
- type HTTPReader
- type JobsHolder
- type MockRestoreHandler
- type OSDiskAccessor
- type Reader
- type Restore
- type RestoreGo
- type RestoreHandler
- type RestoreManager
- type RestoreMock
- type RetryService
- type S3ConfigurationManager
- type S3Context
- type S3ManagerBuilder
- type S3ManagerBuilderImpl
- type StorageAccessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCluster ¶
AddCluster adds a new AerospikeCluster to the configuration if a cluster with the same name doesn't already exist.
func AddPolicy ¶
AddPolicy adds a new BackupPolicy to the configuration if a policy with the same name doesn't already exist.
func AddRoutine ¶
AddRoutine adds a new BackupRoutine to the configuration if a routine with the same name doesn't already exist.
func AddStorage ¶
AddStorage adds a new Storage to the configuration if a storage with the same name doesn't already exist.
func BuildBackupBackends ¶
func BuildBackupBackends(config *model.Config) map[string]*BackupBackend
func DeleteCluster ¶
DeleteCluster deletes an AerospikeCluster from the configuration if it is not used in any backup routine.
func DeletePolicy ¶
DeletePolicy deletes a BackupPolicy from the configuration.
func DeleteRoutine ¶
DeleteRoutine deletes a BackupRoutine from the configuration.
func DeleteStorage ¶
DeleteStorage deletes a Storage from the configuration if it is not used in any policy.
func NewAdHocFullBackupJobForRoutine ¶
NewAdHocFullBackupJobForRoutine returns a new full backup job for the routine name.
func NewRunningJob ¶
func NewRunningJob(startTime time.Time, done, total uint64) *model.RunningJob
NewRunningJob created new RunningJob with calculated estimated time and percentage.
func RestoreJobStatus ¶
func RestoreJobStatus(job *jobInfo) *model.RestoreJobStatus
RestoreJobStatus returns the status of a restore job. The information included in the response depends on the job status:
- model.JobStatusRunning -> current statistics and estimation.
- model.JobStatusDone -> statistics.
- status model.JobStatusFailed -> error.
func ScheduleBackup ¶
func ScheduleBackup(ctx context.Context, config *model.Config, handlers BackupHandlerHolder, ) (quartz.Scheduler, error)
ScheduleBackup creates a new quartz.Scheduler, schedules all the configured backup jobs, starts and returns the scheduler.
func UpdateCluster ¶
UpdateCluster updates an existing AerospikeCluster in the configuration.
func UpdatePolicy ¶
UpdatePolicy updates an existing BackupPolicy in the configuration.
func UpdateRoutine ¶
UpdateRoutine updates an existing BackupRoutine in the configuration.
Types ¶
type AerospikeClientFactory ¶
type AerospikeClientFactory interface {
NewClientWithPolicyAndHost(policy *as.ClientPolicy, hosts ...*as.Host) (backup.AerospikeClient, error)
}
AerospikeClientFactory defines an interface for creating new clients.
type BackendHolderImpl ¶
func NewBackupBackends ¶
func NewBackupBackends(config *model.Config) *BackendHolderImpl
func (*BackendHolderImpl) Get ¶
func (b *BackendHolderImpl) Get(name string) (*BackupBackend, bool)
func (*BackendHolderImpl) GetReader ¶
func (b *BackendHolderImpl) GetReader(name string) (BackupListReader, bool)
func (*BackendHolderImpl) SetData ¶
func (b *BackendHolderImpl) SetData(backends map[string]*BackupBackend)
type BackendsHolder ¶
type BackendsHolder interface { // GetReader returns BackupBackend for routine as BackupListReader. GetReader(routineName string) (BackupListReader, bool) // Get returns BackupBackend for routine. Get(routineName string) (*BackupBackend, bool) // SetData replaces stored backends. SetData(backends map[string]*BackupBackend) }
BackendsHolder is an interface for storing backup backends. We need it because same backends are used in API handlers and backup jobs.
type Backup ¶
type Backup interface { BackupRun( ctx context.Context, backupRoutine *model.BackupRoutine, backupPolicy *model.BackupPolicy, client *backup.Client, storage *model.Storage, secretAgent *model.SecretAgent, timebounds model.TimeBounds, namespace string, path *string, ) (BackupHandler, error) }
Backup represents a backup service.
type BackupBackend ¶
type BackupBackend struct { StorageAccessor // contains filtered or unexported fields }
BackupBackend handles the backup management logic, employing a StorageAccessor implementation for I/O operations.
func (*BackupBackend) FindIncrementalBackupsForNamespace ¶
func (b *BackupBackend) FindIncrementalBackupsForNamespace(bounds *model.TimeBounds, namespace string, ) ([]model.BackupDetails, error)
FindIncrementalBackupsForNamespace returns all incremental backups in given range, sorted by time.
func (*BackupBackend) FindLastFullBackup ¶
func (b *BackupBackend) FindLastFullBackup(toTime time.Time) ([]model.BackupDetails, error)
FindLastFullBackup returns last full backup prior to given time.
func (*BackupBackend) FullBackupInProgress ¶
func (b *BackupBackend) FullBackupInProgress() *atomic.Bool
func (*BackupBackend) FullBackupList ¶
func (b *BackupBackend) FullBackupList(timebounds *model.TimeBounds) ([]model.BackupDetails, error)
FullBackupList returns a list of available full backups.
func (*BackupBackend) IncrementalBackupList ¶
func (b *BackupBackend) IncrementalBackupList(timebounds *model.TimeBounds, ) ([]model.BackupDetails, error)
IncrementalBackupList returns a list of available incremental backups.
func (*BackupBackend) ReadClusterConfiguration ¶
func (b *BackupBackend) ReadClusterConfiguration(path string) ([]byte, error)
type BackupGo ¶
type BackupGo struct { }
BackupGo implements the Backup interface.
func (*BackupGo) BackupRun ¶
func (b *BackupGo) BackupRun( ctx context.Context, backupRoutine *model.BackupRoutine, backupPolicy *model.BackupPolicy, client *backup.Client, storage *model.Storage, secretAgent *model.SecretAgent, timebounds model.TimeBounds, namespace string, path *string, ) (BackupHandler, error)
BackupRun creates a backup.Client and initiates the backup operation. A backup handler is returned to monitor the job status.
type BackupHandler ¶
type BackupHandler interface { // GetStats returns the statistics of the backup job. GetStats() *models.BackupStats // Wait waits for the backup job to complete and returns an error if the // job failed. Wait() error }
BackupHandler represents a backup handler returned by the backup client.
type BackupHandlerHolder ¶
type BackupHandlerHolder map[string]*BackupRoutineHandler
BackupHandlerHolder stores backupHandlers by routine name
func ApplyNewConfig ¶
func ApplyNewConfig(scheduler quartz.Scheduler, config *model.Config, backends BackendsHolder, manager ClientManager, ) (BackupHandlerHolder, error)
func MakeHandlers ¶
func MakeHandlers(clientManager ClientManager, config *model.Config, backends BackendsHolder, ) BackupHandlerHolder
MakeHandlers creates and returns a map of backup handlers per the configured routines.
type BackupListReader ¶
type BackupListReader interface { // FullBackupList returns a list of available full backups. // The parameters are timestamp filters by creation time (epoch millis), // where from is inclusive and to is exclusive. FullBackupList(timebounds *model.TimeBounds) ([]model.BackupDetails, error) // IncrementalBackupList returns a list of available incremental backups. // The parameters are timestamp filters by creation time (epoch millis), // where from is inclusive and to is exclusive. IncrementalBackupList(timebounds *model.TimeBounds) ([]model.BackupDetails, error) // ReadClusterConfiguration return backed up cluster configuration as a compressed zip. ReadClusterConfiguration(path string) ([]byte, error) // FindLastFullBackup returns last full backup prior to given time. // Each element of an array is backup of a namespace. FindLastFullBackup(toTime time.Time) ([]model.BackupDetails, error) // FindIncrementalBackupsForNamespace returns all incremental backups in given range, sorted by time. FindIncrementalBackupsForNamespace(bounds *model.TimeBounds, namespace string) ([]model.BackupDetails, error) }
BackupListReader allows to read list of existing backups.
type BackupRoutineHandler ¶
type BackupRoutineHandler struct {
// contains filtered or unexported fields
}
BackupRoutineHandler implements backup logic for single routine.
func (*BackupRoutineHandler) GetCurrentStat ¶
func (h *BackupRoutineHandler) GetCurrentStat() *model.CurrentBackups
type ClientManager ¶
type ClientManager interface { // GetClient returns a backup client by aerospike cluster name (new or cached). GetClient(string) (*backup.Client, error) // CreateClient creates a new backup client. CreateClient(*model.AerospikeCluster) (*backup.Client, error) // Close ensures that the specified backup client is closed. Close(*backup.Client) }
ClientManager is responsible for creating and closing backup clients.
type ClientManagerImpl ¶
type ClientManagerImpl struct {
// contains filtered or unexported fields
}
ClientManagerImpl implements ClientManager. Is responsible for creating and closing backup clients.
func NewClientManager ¶
func NewClientManager(clusters map[string]*model.AerospikeCluster, aerospikeClientFactory AerospikeClientFactory, ) *ClientManagerImpl
NewClientManager creates a new ClientManagerImpl.
func (*ClientManagerImpl) Close ¶
func (cm *ClientManagerImpl) Close(client *backup.Client)
Close ensures that the specified backup client is closed.
func (*ClientManagerImpl) CreateClient ¶
func (cm *ClientManagerImpl) CreateClient(cluster *model.AerospikeCluster) (*backup.Client, error)
CreateClient creates a new backup client given the aerospike cluster configuration.
func (*ClientManagerImpl) GetClient ¶
func (cm *ClientManagerImpl) GetClient(clusterName string) (*backup.Client, error)
GetClient returns a backup client by aerospike cluster name (new or cached).
type ConfigManagerBuilder ¶
type ConfigManagerBuilder struct {
// contains filtered or unexported fields
}
func NewConfigManagerBuilder ¶
func NewConfigManagerBuilder() *ConfigManagerBuilder
NewConfigManagerBuilder returns a new ConfigManagerBuilder.
func (*ConfigManagerBuilder) NewConfigManager ¶
func (b *ConfigManagerBuilder) NewConfigManager(configFile string, remote bool, ) (ConfigurationManager, error)
NewConfigManager returns a new ConfigurationManager.
type ConfigurationManager ¶
type ConfigurationManager interface { ReadConfiguration() (*model.Config, error) WriteConfiguration(config *model.Config) error }
func NewFileConfigurationManager ¶
func NewFileConfigurationManager(path string) ConfigurationManager
NewFileConfigurationManager returns a new FileConfigurationManager.
func NewHTTPConfigurationManager ¶
func NewHTTPConfigurationManager(uri string) ConfigurationManager
NewHTTPConfigurationManager returns a new HTTPConfigurationManager.
type DefaultClientFactory ¶
type DefaultClientFactory struct{}
DefaultClientFactory is the default implementation of AerospikeClientFactory.
func (*DefaultClientFactory) NewClientWithPolicyAndHost ¶
func (f *DefaultClientFactory) NewClientWithPolicyAndHost( policy *as.ClientPolicy, hosts ...*as.Host, ) (backup.AerospikeClient, error)
NewClientWithPolicyAndHost creates a new Aerospike client with the given policy and hosts.
type FileConfigurationManager ¶
FileConfigurationManager implements the ConfigurationManager interface, performing I/O operations on local storage.
func (*FileConfigurationManager) ReadConfiguration ¶
func (cm *FileConfigurationManager) ReadConfiguration() (*model.Config, error)
ReadConfiguration reads the configuration from the given file path.
func (*FileConfigurationManager) WriteConfiguration ¶
func (cm *FileConfigurationManager) WriteConfiguration(config *model.Config) error
WriteConfiguration writes the configuration to the given file path.
type FileReader ¶
type FileReader struct{}
type HTTPConfigurationManager ¶
type HTTPConfigurationManager struct {
// contains filtered or unexported fields
}
HTTPConfigurationManager implements the ConfigurationManager interface, performing I/O operations via the HTTP(S) protocol.
func (*HTTPConfigurationManager) ReadConfiguration ¶
func (h *HTTPConfigurationManager) ReadConfiguration() (*model.Config, error)
ReadConfiguration reads and returns the configuration using a URL.
func (*HTTPConfigurationManager) WriteConfiguration ¶
func (h *HTTPConfigurationManager) WriteConfiguration(_ *model.Config) error
WriteConfiguration is unsupported for HTTPConfigurationManager.
type HTTPReader ¶
type HTTPReader struct{}
type JobsHolder ¶
type MockRestoreHandler ¶
type MockRestoreHandler struct { }
MockRestoreHandler is a mock implementation of the RestoreHandler interface.
func (*MockRestoreHandler) GetStats ¶
func (m *MockRestoreHandler) GetStats() *models.RestoreStats
func (*MockRestoreHandler) Wait ¶
func (m *MockRestoreHandler) Wait() error
type OSDiskAccessor ¶
type OSDiskAccessor struct { }
OSDiskAccessor is responsible for IO operation on local disk.
func NewOSDiskAccessor ¶
func NewOSDiskAccessor() *OSDiskAccessor
NewOSDiskAccessor returns a new OSDiskAccessor.
func (*OSDiskAccessor) DeleteFolder ¶
func (o *OSDiskAccessor) DeleteFolder(pathToDelete string) error
type Restore ¶
type Restore interface { RestoreRun( ctx context.Context, client *backup.Client, restoreRequest *model.RestoreRequestInternal, ) (RestoreHandler, error) }
Restore represents a restore service.
type RestoreGo ¶
type RestoreGo struct { }
RestoreGo implements the Restore interface.
func (*RestoreGo) RestoreRun ¶
func (r *RestoreGo) RestoreRun( ctx context.Context, client *backup.Client, restoreRequest *model.RestoreRequestInternal, ) (RestoreHandler, error)
RestoreRun creates a backup.Client and initiates the restore operation. A restore handler is returned to monitor the job status.
type RestoreHandler ¶
type RestoreHandler interface { // GetStats returns the statistics of the restore job. GetStats() *models.RestoreStats // Wait waits for the restore job to complete and returns an error if the // job failed. Wait() error }
RestoreHandler represents a restore handler returned by the backup client.
type RestoreManager ¶
type RestoreManager interface { // Restore starts a restore process using the given request. // Returns the job id as a unique identifier. Restore(request *model.RestoreRequestInternal) (model.RestoreJobID, error) // RestoreByTime starts a restore by time process using the given request. // Returns the job id as a unique identifier. RestoreByTime(request *model.RestoreTimestampRequest) (model.RestoreJobID, error) // JobStatus returns status for the given job id. JobStatus(jobID model.RestoreJobID) (*model.RestoreJobStatus, error) // RetrieveConfiguration return backed up Aerospike configuration. RetrieveConfiguration(routine string, toTime time.Time) ([]byte, error) }
func NewRestoreManager ¶
func NewRestoreManager(backends BackendsHolder, config *model.Config, restoreService Restore, clientManager ClientManager, ) RestoreManager
NewRestoreManager returns a new dataRestorer instance.
type RestoreMock ¶
type RestoreMock struct { }
RestoreMock mocks the Restore interface. Used in CI workflows to skip building the C shared libraries.
func NewRestoreMock ¶
func NewRestoreMock() *RestoreMock
NewRestoreMock returns a new RestoreMock instance.
func (*RestoreMock) RestoreRun ¶
func (r *RestoreMock) RestoreRun(_ context.Context, _ *backup.Client, _ *model.RestoreRequestInternal) (RestoreHandler, error)
RestoreRun mocks the interface method.
type RetryService ¶
type RetryService struct {
// contains filtered or unexported fields
}
RetryService a service for retrying a function with a specified interval and number of attempts.
func NewRetryService ¶
func NewRetryService(label string) *RetryService
NewRetryService returns a new RetryService instance.
- label is used for logging purposes only.
type S3ConfigurationManager ¶
type S3ConfigurationManager struct {
*S3Context
}
S3ConfigurationManager implements the ConfigurationManager interface, performing I/O operations on AWS S3.
func (*S3ConfigurationManager) ReadConfiguration ¶
func (s *S3ConfigurationManager) ReadConfiguration() (*model.Config, error)
ReadConfiguration reads and returns the configuration from S3.
func (*S3ConfigurationManager) WriteConfiguration ¶
func (s *S3ConfigurationManager) WriteConfiguration(config *model.Config) error
WriteConfiguration writes the configuration to S3.
type S3Context ¶
type S3Context struct {
// contains filtered or unexported fields
}
S3Context is responsible for performing basic operations on S3.
func NewS3Context ¶
NewS3Context returns a new S3Context.
func (*S3Context) DeleteFolder ¶
func (*S3Context) ValidateStorageContainsBackup ¶
type S3ManagerBuilder ¶
type S3ManagerBuilder interface { // NewS3ConfigurationManager returns a new S3ConfigurationManager. NewS3ConfigurationManager(configStorage *model.Storage) (ConfigurationManager, error) }
S3ManagerBuilder defines the interface for building S3ConfigurationManager.
type S3ManagerBuilderImpl ¶
type S3ManagerBuilderImpl struct{}
func (S3ManagerBuilderImpl) NewS3ConfigurationManager ¶
func (builder S3ManagerBuilderImpl) NewS3ConfigurationManager(configStorage *model.Storage, ) (ConfigurationManager, error)
type StorageAccessor ¶
Source Files ¶
- aerospike_service.go
- backup_backend.go
- backup_backends_holder.go
- backup_go.go
- backup_job.go
- backup_list_reader.go
- backup_routine_handler.go
- backup_scheduler.go
- client_manager.go
- configuration_manager.go
- configuration_manager_http.go
- configuration_manager_local.go
- configuration_manager_s3.go
- configuration_service_cluster.go
- configuration_service_policy.go
- configuration_service_routine.go
- configuration_service_storage.go
- estimates.go
- jobs_holder.go
- metrics.go
- os_accessor.go
- restore.go
- restore_config.go
- restore_data.go
- restore_go.go
- restore_mock.go
- retry_service.go
- s3_context.go
- storage_accessor.go
- types.go