Documentation ¶
Index ¶
- Constants
- func GetRepoDomain() string
- func GetRepoUser() string
- func WithConfigFile(workPath string, repoID string) func(*RepoOptions) error
- func WithDescription(desc string) func(*RepoOptions) error
- func WithGenOptions(genOptions map[string]string) func(*RepoOptions) error
- func WithPassword(getter PasswordGetter, param interface{}) func(*RepoOptions) error
- func WithStoreOptions(getter StoreOptionsGetter, param interface{}) func(*RepoOptions) error
- type AdvancedFeatureInfo
- type BackupRepo
- type BackupRepoService
- type ID
- type ManifestEntryMetadata
- type ManifestFilter
- type ObjectReader
- type ObjectWriteOptions
- type ObjectWriter
- type PasswordGetter
- type RepoManifest
- type RepoOptions
- type StoreOptionsGetter
Constants ¶
const ( // Below consts descrbe the data type of one object. // Metadata: This type describes how the data is organized. // For a file system backup, the Metadata describes a Dir or File. // For a block backup, the Metadata describes a Disk and its incremental link. ObjectDataTypeUnknown int = 0 ObjectDataTypeMetadata int = 1 ObjectDataTypeData int = 2 // Below consts defines the access mode when creating an object for write ObjectDataAccessModeUnknown int = 0 ObjectDataAccessModeFile int = 1 ObjectDataAccessModeBlock int = 2 ObjectDataBackupModeUnknown int = 0 ObjectDataBackupModeFull int = 1 ObjectDataBackupModeInc int = 2 )
const ( StorageTypeS3 = "s3" StorageTypeAzure = "azure" StorageTypeFs = "filesystem" StorageTypeGcs = "gcs" GenOptionMaintainMode = "mode" GenOptionMaintainFull = "full" GenOptionMaintainQuick = "quick" GenOptionOwnerName = "username" GenOptionOwnerDomain = "domainname" StoreOptionS3KeyID = "accessKeyID" StoreOptionS3Provider = "providerName" StoreOptionS3SecretKey = "secretAccessKey" StoreOptionS3Token = "sessionToken" StoreOptionS3Endpoint = "endpoint" StoreOptionS3DisableTLS = "doNotUseTLS" StoreOptionS3DisableTLSVerify = "skipTLSVerify" StoreOptionFsPath = "fspath" StoreOptionGcsReadonly = "readonly" StoreOptionOssBucket = "bucket" StoreOptionOssRegion = "region" StoreOptionCACert = "caCert" StoreOptionCredentialFile = "credFile" StoreOptionPrefix = "prefix" StoreOptionPrefixName = "unified-repo" StoreOptionGenHashAlgo = "hashAlgo" StoreOptionGenEncryptAlgo = "encryptAlgo" StoreOptionGenSplitAlgo = "splitAlgo" StoreOptionGenRetentionMode = "retentionMode" StoreOptionGenRetentionPeriod = "retentionPeriod" StoreOptionGenReadOnly = "readOnly" StoreOptionCacheLimit = "cacheLimitMB" ThrottleOptionReadOps = "readOPS" ThrottleOptionWriteOps = "writeOPS" ThrottleOptionListOps = "listOPS" ThrottleOptionUploadBytes = "uploadBytes" ThrottleOptionDownloadBytes = "downloadBytes" )
Variables ¶
This section is empty.
Functions ¶
func GetRepoDomain ¶
func GetRepoDomain() string
GetRepoDomain returns the default user domain that is used to manipulate the Unified Repo
func GetRepoUser ¶
func GetRepoUser() string
GetRepoUser returns the default username that is used to manipulate the Unified Repo
func WithConfigFile ¶
func WithConfigFile(workPath string, repoID string) func(*RepoOptions) error
WithConfigFile sets the ConfigFilePath to RepoOptions
func WithDescription ¶
func WithDescription(desc string) func(*RepoOptions) error
WithDescription sets the Description to RepoOptions
func WithGenOptions ¶
func WithGenOptions(genOptions map[string]string) func(*RepoOptions) error
WithGenOptions sets the GeneralOptions to RepoOptions
func WithPassword ¶
func WithPassword(getter PasswordGetter, param interface{}) func(*RepoOptions) error
WithPassword sets the RepoPassword to RepoOptions, the password is acquired through the provided interface
func WithStoreOptions ¶
func WithStoreOptions(getter StoreOptionsGetter, param interface{}) func(*RepoOptions) error
WithStoreOptions sets the StorageOptions to RepoOptions, the store options are acquired through the provided interface
Types ¶
type AdvancedFeatureInfo ¶ added in v1.14.0
type AdvancedFeatureInfo struct {
MultiPartBackup bool // if set to true, it means the repo supports multiple-part backup
}
type BackupRepo ¶
type BackupRepo interface { // OpenObject opens an existing object for read. // id: the object's unified identifier. OpenObject(ctx context.Context, id ID) (ObjectReader, error) // GetManifest gets a manifest data from the backup repository. GetManifest(ctx context.Context, id ID, mani *RepoManifest) error // FindManifests gets one or more manifest data that match the given labels FindManifests(ctx context.Context, filter ManifestFilter) ([]*ManifestEntryMetadata, error) // NewObjectWriter creates a new object and return the object's writer interface. // return: A unified identifier of the object on success. NewObjectWriter(ctx context.Context, opt ObjectWriteOptions) ObjectWriter // PutManifest saves a manifest object into the backup repository. PutManifest(ctx context.Context, mani RepoManifest) (ID, error) // DeleteManifest deletes a manifest object from the backup repository. DeleteManifest(ctx context.Context, id ID) error // Flush flushes all the backup repository data Flush(ctx context.Context) error // GetAdvancedFeatures returns the support for advanced features GetAdvancedFeatures() AdvancedFeatureInfo // ConcatenateObjects is for multiple-part backup, it concatenates multiple objects into one object ConcatenateObjects(ctx context.Context, objectIDs []ID) (ID, error) // Time returns the local time of the backup repository. It may be different from the time of the caller Time() time.Time // Close closes the backup repository Close(ctx context.Context) error }
BackupRepo provides the access to the backup repository
type BackupRepoService ¶
type BackupRepoService interface { // Init creates a backup repository or connect to an existing backup repository. // repoOption: option to the backup repository and the underlying backup storage. // createNew: indicates whether to create a new or connect to an existing backup repository. Init(ctx context.Context, repoOption RepoOptions, createNew bool) error // Open opens an backup repository that has been created/connected. // repoOption: options to open the backup repository and the underlying storage. Open(ctx context.Context, repoOption RepoOptions) (BackupRepo, error) // Maintain is periodically called to maintain the backup repository to eliminate redundant data. // repoOption: options to maintain the backup repository. Maintain(ctx context.Context, repoOption RepoOptions) error // DefaultMaintenanceFrequency returns the defgault frequency of maintenance, callers refer this // frequency to maintain the backup repository to get the best maintenance performance DefaultMaintenanceFrequency() time.Duration }
BackupRepoService is used to initialize, open or maintain a backup repository
type ManifestEntryMetadata ¶
type ManifestEntryMetadata struct { ID ID // The ID of the manifest data Length int32 // The data size of the manifest data Labels map[string]string // Labels saved together with the manifest data ModTime time.Time // Modified time of the manifest data }
ManifestEntryMetadata is the metadata describing one manifest data
type ManifestFilter ¶
type ObjectReader ¶
type ObjectReader interface { io.ReadCloser io.Seeker // Length returns the logical size of the object Length() int64 }
type ObjectWriteOptions ¶
type ObjectWriteOptions struct { FullPath string // Full logical path of the object DataType int // OBJECT_DATA_TYPE_* Description string // A description of the object, could be empty Prefix ID // A prefix of the name used to save the object AccessMode int // OBJECT_DATA_ACCESS_* BackupMode int // OBJECT_DATA_BACKUP_* AsyncWrites int // Num of async writes for the object, 0 means no async write }
ObjectWriteOptions defines the options when creating an object for write
type ObjectWriter ¶
type ObjectWriter interface { io.WriteCloser // Seeker is used in the cases that the object is not written sequentially io.Seeker // Checkpoint is periodically called to preserve the state of data written to the repo so far. // Checkpoint returns a unified identifier that represent the current state. // An empty ID could be returned on success if the backup repository doesn't support this. Checkpoint() (ID, error) // Result waits for the completion of the object write. // Result returns the object's unified identifier after the write completes. Result() (ID, error) }
type PasswordGetter ¶
PasswordGetter defines the method to get a repository password.
type RepoManifest ¶
type RepoManifest struct { Payload interface{} // The user data of manifest Metadata *ManifestEntryMetadata // The metadata data of manifest }
type RepoOptions ¶
type RepoOptions struct { // StorageType is a repository specific string to identify a backup storage, i.e., "s3", "filesystem" StorageType string // RepoPassword is the backup repository's password, if any RepoPassword string // ConfigFilePath is a custom path to save the repository's configuration, if any ConfigFilePath string // GeneralOptions takes other repository specific options GeneralOptions map[string]string // StorageOptions takes storage specific options StorageOptions map[string]string // Description is a description of the backup repository/backup repository operation. // It is for logging/debugging purpose only and doesn't control any behavior of the backup repository. Description string }
func NewRepoOptions ¶
func NewRepoOptions(optionFuncs ...func(*RepoOptions) error) (*RepoOptions, error)
NewRepoOptions creates a new RepoOptions for different purpose