Documentation
¶
Index ¶
- type MigrationBackendService
- func (d *MigrationBackendService) Delete(ctx context.Context, path string) error
- func (d *MigrationBackendService) DisableMigration(ctx context.Context)
- func (d *MigrationBackendService) EnableMigration(ctx context.Context, target domain.FileBackend, mode MigrationMode, ...) error
- func (d *MigrationBackendService) Get(ctx context.Context, path string) ([]byte, error)
- func (d *MigrationBackendService) IsMigrating() bool
- func (d *MigrationBackendService) MigrateTo(ctx context.Context, prefix string, onProgress func(file string), ...) error
- func (d *MigrationBackendService) MigrationStatus(ctx context.Context) (completed int64, total int64)
- func (d *MigrationBackendService) Put(ctx context.Context, path string, data []byte) error
- type MigrationConfig
- type MigrationMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MigrationBackendService ¶
type MigrationBackendService struct {
// contains filtered or unexported fields
}
MigrationBackendService manages dual-backend behaviour and migration.
func NewMigrationBackend ¶
func NewMigrationBackend(logger domain.BucktLogger, primary domain.FileBackend, secondary domain.FileBackend) *MigrationBackendService
NewMigrationBackend unchanged except returns *MigrationBackendService
Example usage:
var logger = domain.NewLogger() var localBackend = domain.NewLocalFileBackend() var s3Backend = domain.NewS3FileBackend()
var mgr = NewMigrationBackend(logger, localBackend, s3Backend)
mgr.EnableMigration(ctx, s3Backend, MigrateModeToSecondary, &MigrationConfig{
Concurrency: 16,
DeleteAfterCopy: false,
PersistPath: "/var/run/bucket_migration_state.json",
})
go func() {
err := mgr.MigrateTo(ctx, "images/", func(p string){ fmt.Println("migrated", p) }, func(p string, e error){ fmt.Println("err", p, e) })
if err != nil {
log.Println("migration finished with error", err)
}
}()
defer func() {
mgr.DisableMigration(ctx)
}()
func (*MigrationBackendService) Delete ¶
func (d *MigrationBackendService) Delete(ctx context.Context, path string) error
func (*MigrationBackendService) DisableMigration ¶
func (d *MigrationBackendService) DisableMigration(ctx context.Context)
func (*MigrationBackendService) EnableMigration ¶
func (d *MigrationBackendService) EnableMigration(ctx context.Context, target domain.FileBackend, mode MigrationMode, cfg *MigrationConfig) error
func (*MigrationBackendService) IsMigrating ¶
func (d *MigrationBackendService) IsMigrating() bool
func (*MigrationBackendService) MigrationStatus ¶
func (d *MigrationBackendService) MigrationStatus(ctx context.Context) (completed int64, total int64)
type MigrationConfig ¶
type MigrationMode ¶
type MigrationMode int
const ( MigrateModeNone MigrationMode = iota MigrateModeToSecondary // primary --> secondary (e.g., local -> s3) MigrateModeFromSecondary // secondary --> primary (e.g., s3 -> local) )
Click to show internal directories.
Click to hide internal directories.