migration

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSeedXORLeech = errors.New("can either seed or leech, but not both at the same time")
)
View Source
var (
	ErrStartingTrackFailed = errors.New("starting track failed")
)

Functions

This section is empty.

Types

type FileLeecher

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

func NewFileLeecher

func NewFileLeecher(
	ctx context.Context,

	local backend.Backend,
	remote *services.SeederRemote,

	options *LeecherOptions,
	hooks *LeecherHooks,

	serverOptions *server.Options,
	clientOptions *client.Options,
) *FileLeecher

func (*FileLeecher) Close

func (l *FileLeecher) Close() error

func (*FileLeecher) Finalize

func (l *FileLeecher) Finalize() (*os.File, error)

func (*FileLeecher) Open

func (l *FileLeecher) Open() error

func (*FileLeecher) Release

func (l *FileLeecher) Release() (
	*mount.DirectPathMount,
	chan error,
	*sync.WaitGroup,
	string,
	*os.File,
)

func (*FileLeecher) Wait

func (l *FileLeecher) Wait() error

type FileMigrator

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

func NewFileMigrator

func NewFileMigrator(
	ctx context.Context,

	local backend.Backend,

	options *MigratorOptions,
	hooks *MigratorHooks,

	serverOptions *server.Options,
	clientOptions *client.Options,
) *FileMigrator

func (*FileMigrator) Close

func (s *FileMigrator) Close() error

func (*FileMigrator) Leech

func (s *FileMigrator) Leech(
	remote *services.SeederRemote,
) (
	finalize func() (
		seed func() (
			svc *services.SeederService,
			err error,
		),

		file *os.File,
		err error,
	),

	err error,
)

func (*FileMigrator) Seed

func (s *FileMigrator) Seed() (
	file *os.File,
	svc *services.SeederService,
	err error,
)

func (*FileMigrator) Wait

func (s *FileMigrator) Wait() error

type FileSeeder

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

func NewFileSeeder

func NewFileSeeder(
	local backend.Backend,

	options *SeederOptions,
	hooks *SeederHooks,

	serverOptions *server.Options,
	clientOptions *client.Options,
) *FileSeeder

func NewFileSeederFromLeecher

func NewFileSeederFromLeecher(
	local backend.Backend,

	options *SeederOptions,
	hooks *SeederHooks,

	dev *mount.DirectPathMount,
	errs chan error,
	wg *sync.WaitGroup,
	devicePath string,
	serverFile *os.File,

	deviceFile *os.File,
) *FileSeeder

func (*FileSeeder) Close

func (s *FileSeeder) Close() error

func (*FileSeeder) Open

func (s *FileSeeder) Open() (*os.File, *services.SeederService, error)

func (*FileSeeder) Wait

func (s *FileSeeder) Wait() error

type LeecherHooks

type LeecherHooks struct {
	OnAfterSync func(dirtyOffsets []int64) error

	OnBeforeClose func() error

	OnChunkIsLocal func(off int64) error
}

type LeecherOptions

type LeecherOptions struct {
	ChunkSize int64

	PullWorkers  int64
	PullPriority func(off int64) int64

	Verbose bool
}

type MigratorHooks

type MigratorHooks struct {
	OnBeforeSync func() error
	OnAfterSync  func(dirtyOffsets []int64) error

	OnBeforeClose func() error

	OnChunkIsLocal func(off int64) error
}

type MigratorOptions

type MigratorOptions struct {
	ChunkSize    int64
	MaxChunkSize int64

	PullWorkers  int64
	PullPriority func(off int64) int64

	Verbose bool
}

type PathLeecher

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

func NewPathLeecher

func NewPathLeecher(
	ctx context.Context,

	local backend.Backend,
	remote *services.SeederRemote,

	options *LeecherOptions,
	hooks *LeecherHooks,

	serverOptions *server.Options,
	clientOptions *client.Options,
) *PathLeecher

func (*PathLeecher) Close

func (l *PathLeecher) Close() error

func (*PathLeecher) Finalize

func (l *PathLeecher) Finalize() (string, error)

func (*PathLeecher) Open

func (l *PathLeecher) Open() (int64, error)

func (*PathLeecher) Release

func (l *PathLeecher) Release() (
	*mount.DirectPathMount,
	chan error,
	*sync.WaitGroup,
	string,
	*os.File,
)

func (*PathLeecher) Wait

func (l *PathLeecher) Wait() error

type PathMigrator

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

func NewPathMigrator

func NewPathMigrator(
	ctx context.Context,

	local backend.Backend,

	options *MigratorOptions,
	hooks *MigratorHooks,

	serverOptions *server.Options,
	clientOptions *client.Options,
) *PathMigrator

func (*PathMigrator) Close

func (s *PathMigrator) Close() error

func (*PathMigrator) Leech

func (s *PathMigrator) Leech(
	remote *services.SeederRemote,
) (
	finalize func() (
		seed func() (
			svc *services.SeederService,
			err error,
		),

		path string,
		err error,
	),

	size int64,
	err error,
)

func (*PathMigrator) Seed

func (s *PathMigrator) Seed() (
	path string,
	size int64,
	svc *services.SeederService,
	err error,
)

func (*PathMigrator) Wait

func (s *PathMigrator) Wait() error

type PathSeeder

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

func NewPathSeeder

func NewPathSeeder(
	local backend.Backend,

	options *SeederOptions,
	hooks *SeederHooks,

	serverOptions *server.Options,
	clientOptions *client.Options,
) *PathSeeder

func NewPathSeederFromLeecher

func NewPathSeederFromLeecher(
	local backend.Backend,

	options *SeederOptions,
	hooks *SeederHooks,

	dev *mount.DirectPathMount,
	errs chan error,
	wg *sync.WaitGroup,
	devicePath string,
	serverFile *os.File,
) *PathSeeder

func (*PathSeeder) Close

func (s *PathSeeder) Close() error

func (*PathSeeder) Open

func (*PathSeeder) Wait

func (s *PathSeeder) Wait() error

type SeederHooks

type SeederHooks struct {
	OnBeforeSync func() error

	OnBeforeClose func() error
}

type SeederOptions

type SeederOptions struct {
	ChunkSize    int64
	MaxChunkSize int64

	Verbose bool
}

type SliceLeecher

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

func NewSliceLeecher

func NewSliceLeecher(
	ctx context.Context,

	local backend.Backend,
	remote *services.SeederRemote,

	options *LeecherOptions,
	hooks *LeecherHooks,

	serverOptions *server.Options,
	clientOptions *client.Options,
) *SliceLeecher

func (*SliceLeecher) Close

func (l *SliceLeecher) Close() error

func (*SliceLeecher) Finalize

func (l *SliceLeecher) Finalize() ([]byte, error)

func (*SliceLeecher) Open

func (l *SliceLeecher) Open() error

func (*SliceLeecher) Release

func (l *SliceLeecher) Release() (
	*mount.DirectPathMount,
	chan error,
	*sync.WaitGroup,
	string,
	*os.File,
)

func (*SliceLeecher) Wait

func (l *SliceLeecher) Wait() error

type SliceMigrator

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

func NewSliceMigrator

func NewSliceMigrator(
	ctx context.Context,

	local backend.Backend,

	options *MigratorOptions,
	hooks *MigratorHooks,

	serverOptions *server.Options,
	clientOptions *client.Options,
) *SliceMigrator

func (*SliceMigrator) Close

func (s *SliceMigrator) Close() error

func (*SliceMigrator) Leech

func (s *SliceMigrator) Leech(
	remote *services.SeederRemote,
) (
	finalize func() (
		seed func() (
			svc *services.SeederService,
			err error,
		),

		slice []byte,
		err error,
	),

	err error,
)

func (*SliceMigrator) Seed

func (s *SliceMigrator) Seed() (
	slice []byte,
	svc *services.SeederService,
	err error,
)

func (*SliceMigrator) Wait

func (s *SliceMigrator) Wait() error

type SliceSeeder

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

func NewSliceSeeder

func NewSliceSeeder(
	local backend.Backend,

	options *SeederOptions,
	hooks *SeederHooks,

	serverOptions *server.Options,
	clientOptions *client.Options,
) *SliceSeeder

func NewSliceSeederFromLeecher

func NewSliceSeederFromLeecher(
	local backend.Backend,

	options *SeederOptions,
	hooks *SeederHooks,

	dev *mount.DirectPathMount,
	errs chan error,
	wg *sync.WaitGroup,
	devicePath string,
	releasedServerFile *os.File,

	deviceSlice []byte,
) *SliceSeeder

func (*SliceSeeder) Close

func (s *SliceSeeder) Close() error

func (*SliceSeeder) Open

func (s *SliceSeeder) Open() ([]byte, *services.SeederService, error)

func (*SliceSeeder) Wait

func (s *SliceSeeder) Wait() error

Jump to

Keyboard shortcuts

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