mock

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	AcquireHaltLockFunc func(ctx context.Context, primaryURL string, nodeID uint64, name string, lockID int64) (*litefs.HaltLock, error)
	ReleaseHaltLockFunc func(ctx context.Context, primaryURL string, nodeID uint64, name string, lockID int64) error
	CommitFunc          func(ctx context.Context, primaryURL string, nodeID uint64, name string, lockID int64, r io.Reader) error
	StreamFunc          func(ctx context.Context, primaryURL string, nodeID uint64, posMap map[string]ltx.Pos, filter []string) (litefs.Stream, error)
}

func (*Client) AcquireHaltLock added in v0.4.0

func (c *Client) AcquireHaltLock(ctx context.Context, primaryURL string, nodeID uint64, name string, lockID int64) (*litefs.HaltLock, error)

func (*Client) Commit added in v0.4.0

func (c *Client) Commit(ctx context.Context, primaryURL string, nodeID uint64, name string, lockID int64, r io.Reader) error

func (*Client) ReleaseHaltLock added in v0.4.0

func (c *Client) ReleaseHaltLock(ctx context.Context, primaryURL string, nodeID uint64, name string, lockID int64) error

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, primaryURL string, nodeID uint64, posMap map[string]ltx.Pos, filter []string) (litefs.Stream, error)

type Lease

type Lease struct {
	IDFunc        func() string
	RenewedAtFunc func() time.Time
	TTLFunc       func() time.Duration
	RenewFunc     func(ctx context.Context) error
	HandoffFunc   func(ctx context.Context, nodeID uint64) error
	HandoffChFunc func() <-chan uint64
	CloseFunc     func() error
}

func (*Lease) Close

func (l *Lease) Close() error

func (*Lease) Handoff added in v0.4.0

func (l *Lease) Handoff(ctx context.Context, nodeID uint64) error

func (*Lease) HandoffCh added in v0.4.0

func (l *Lease) HandoffCh() <-chan uint64

func (*Lease) ID added in v0.4.0

func (l *Lease) ID() string

func (*Lease) Renew

func (l *Lease) Renew(ctx context.Context) error

func (*Lease) RenewedAt

func (l *Lease) RenewedAt() time.Time

func (*Lease) TTL

func (l *Lease) TTL() time.Duration

type Leaser

type Leaser struct {
	CloseFunc           func() error
	HostnameFunc        func() string
	AdvertiseURLFunc    func() string
	AcquireFunc         func(ctx context.Context) (litefs.Lease, error)
	AcquireExistingFunc func(ctx context.Context, leaseID string) (litefs.Lease, error)
	PrimaryInfoFunc     func(ctx context.Context) (litefs.PrimaryInfo, error)
	ClusterIDFunc       func(ctx context.Context) (string, error)
	SetClusterIDFunc    func(ctx context.Context, clusterID string) error
}

func (*Leaser) Acquire

func (l *Leaser) Acquire(ctx context.Context) (litefs.Lease, error)

func (*Leaser) AcquireExisting added in v0.4.0

func (l *Leaser) AcquireExisting(ctx context.Context, leaseID string) (litefs.Lease, error)

func (*Leaser) AdvertiseURL

func (l *Leaser) AdvertiseURL() string

func (*Leaser) Close

func (l *Leaser) Close() error

func (*Leaser) ClusterID added in v0.5.0

func (l *Leaser) ClusterID(ctx context.Context) (string, error)

func (*Leaser) Hostname added in v0.5.7

func (l *Leaser) Hostname() string

func (*Leaser) PrimaryInfo

func (l *Leaser) PrimaryInfo(ctx context.Context) (litefs.PrimaryInfo, error)

func (*Leaser) SetClusterID added in v0.5.0

func (l *Leaser) SetClusterID(ctx context.Context, clusterID string) error

func (*Leaser) Type added in v0.5.0

func (l *Leaser) Type() string

type OS added in v0.5.6

type OS struct {
	Underlying litefs.OS

	CreateFunc    func(op, name string) (*os.File, error)
	MkdirFunc     func(op, path string, perm os.FileMode) error
	MkdirAllFunc  func(op, path string, perm os.FileMode) error
	OpenFunc      func(op, name string) (*os.File, error)
	OpenFileFunc  func(op, name string, flag int, perm os.FileMode) (*os.File, error)
	ReadDirFunc   func(op, name string) ([]os.DirEntry, error)
	ReadFileFunc  func(op, name string) ([]byte, error)
	RemoveFunc    func(op, name string) error
	RemoveAllFunc func(op, name string) error
	RenameFunc    func(op, oldpath, newpath string) error
	StatFunc      func(op, name string) (os.FileInfo, error)
	TruncateFunc  func(op, name string, size int64) error
	WriteFileFunc func(op, name string, data []byte, perm os.FileMode) error
}

func NewOS added in v0.5.6

func NewOS() *OS

NewOS returns a mock OS that defaults to using an underlying system OS.

func (*OS) Create added in v0.5.6

func (m *OS) Create(op, name string) (*os.File, error)

func (*OS) Mkdir added in v0.5.6

func (m *OS) Mkdir(op, path string, perm os.FileMode) error

func (*OS) MkdirAll added in v0.5.6

func (m *OS) MkdirAll(op, path string, perm os.FileMode) error

func (*OS) Open added in v0.5.6

func (m *OS) Open(op, name string) (*os.File, error)

func (*OS) OpenFile added in v0.5.6

func (m *OS) OpenFile(op, name string, flag int, perm os.FileMode) (*os.File, error)

func (*OS) ReadDir added in v0.5.6

func (m *OS) ReadDir(op, name string) ([]os.DirEntry, error)

func (*OS) ReadFile added in v0.5.6

func (m *OS) ReadFile(op, name string) ([]byte, error)

func (*OS) Remove added in v0.5.6

func (m *OS) Remove(op, name string) error

func (*OS) RemoveAll added in v0.5.6

func (m *OS) RemoveAll(op, name string) error

func (*OS) Rename added in v0.5.6

func (m *OS) Rename(op, oldpath, newpath string) error

func (*OS) Stat added in v0.5.6

func (m *OS) Stat(op, name string) (os.FileInfo, error)

func (*OS) Truncate added in v0.5.6

func (m *OS) Truncate(op, name string, size int64) error

func (*OS) WriteFile added in v0.5.6

func (m *OS) WriteFile(op, name string, data []byte, perm os.FileMode) error

type Stream added in v0.5.0

type Stream struct {
	io.ReadCloser
	ClusterIDFunc func() string
}

func (*Stream) ClusterID added in v0.5.0

func (s *Stream) ClusterID() string

Jump to

Keyboard shortcuts

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