file

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	RLockFileSuffix = ".rlock"
	LockFileSuffix  = ".lock"
	TempFileSuffix  = ".temp"
)
View Source
const DefaultRetryDelay = 10 * time.Millisecond
View Source
const DefaultWaitTimeout = 10 * time.Second

Variables

This section is empty.

Functions

func Exists added in v1.6.0

func Exists(path string) bool

func GetTimeoutContext added in v1.9.3

func GetTimeoutContext(ctx context.Context, waitTimeOut time.Duration) (context.Context, context.CancelFunc)

func LockExists added in v1.9.6

func LockExists(path string) bool

func LockFilePath

func LockFilePath(path string) string

func NewAlreadyExistError added in v1.9.8

func NewAlreadyExistError(message string) error

func NewCompositeError added in v1.9.3

func NewCompositeError(err1 error, err2 error) error

func NewContextCanceled added in v1.9.10

func NewContextCanceled() error

func NewContextDone added in v1.9.10

func NewContextDone(message string) error

func NewForcedUnlockError added in v1.6.0

func NewForcedUnlockError(errs []error) error

func NewIOError

func NewIOError(message string) error

func NewLockError

func NewLockError(message string) error

func NewNotExistError added in v1.9.8

func NewNotExistError(message string) error

func NewTimeoutError

func NewTimeoutError(path string) error

func ParseError

func ParseError(err error) error

func RLockExists added in v1.9.6

func RLockExists(path string) bool

func RLockFilePath added in v1.9.6

func RLockFilePath(path string) string

func RandomString added in v1.17.8

func RandomString(length int) string

func TempFilePath added in v1.6.0

func TempFilePath(path string) string

Types

type AlreadyExistError added in v1.9.8

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

func (AlreadyExistError) Error added in v1.9.8

func (e AlreadyExistError) Error() string

type CompositeError added in v1.9.3

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

func (CompositeError) Error added in v1.9.3

func (e CompositeError) Error() string

type Container added in v1.9.3

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

func NewContainer added in v1.9.3

func NewContainer() *Container

func (*Container) Add added in v1.9.3

func (c *Container) Add(path string, handler *Handler) error

func (*Container) Close added in v1.9.3

func (c *Container) Close(h *Handler) error

func (*Container) CloseAll added in v1.9.6

func (c *Container) CloseAll() error

func (*Container) CloseAllWithErrors added in v1.9.6

func (c *Container) CloseAllWithErrors() error

func (*Container) CloseWithErrors added in v1.9.3

func (c *Container) CloseWithErrors(h *Handler) (err error)

func (*Container) Commit added in v1.9.3

func (c *Container) Commit(h *Handler) error

func (*Container) CreateHandlerForCreate added in v1.17.9

func (c *Container) CreateHandlerForCreate(path string) (*Handler, error)

func (*Container) CreateHandlerForRead added in v1.17.9

func (c *Container) CreateHandlerForRead(ctx context.Context, path string, defaultWaitTimeout time.Duration, retryDelay time.Duration) (*Handler, error)

func (*Container) CreateHandlerForUpdate added in v1.17.9

func (c *Container) CreateHandlerForUpdate(ctx context.Context, path string, defaultWaitTimeout time.Duration, retryDelay time.Duration) (*Handler, error)

func (*Container) CreateHandlerWithoutLock added in v1.17.9

func (c *Container) CreateHandlerWithoutLock(ctx context.Context, path string, defaultWaitTimeout time.Duration, retryDelay time.Duration) (*Handler, error)

func (*Container) Keys added in v1.9.3

func (c *Container) Keys() []string

func (*Container) Remove added in v1.9.3

func (c *Container) Remove(path string)

type ContextCanceled added in v1.9.10

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

func (ContextCanceled) Error added in v1.9.10

func (e ContextCanceled) Error() string

type ContextDone added in v1.9.10

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

func (ContextDone) Error added in v1.9.10

func (e ContextDone) Error() string

type ControlFile added in v1.17.9

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

func CreateControlFileContext added in v1.17.9

func CreateControlFileContext(ctx context.Context, filePath string, fileType ControlFileType, retryDelay time.Duration) (*ControlFile, error)

func NewControlFile added in v1.17.9

func NewControlFile(path string, fp *os.File) *ControlFile

func TryCreateLockFile added in v1.17.9

func TryCreateLockFile(filePath string) (*ControlFile, error)

func TryCreateRLockFile added in v1.17.9

func TryCreateRLockFile(filePath string) (controlFile *ControlFile, err error)

func TryCreateTempFile added in v1.17.9

func TryCreateTempFile(filePath string) (*ControlFile, error)

func (*ControlFile) Close added in v1.17.9

func (m *ControlFile) Close() error

func (*ControlFile) CloseWithErrors added in v1.17.9

func (m *ControlFile) CloseWithErrors() []error

type ControlFileType added in v1.17.9

type ControlFileType int
const (
	RLock ControlFileType = iota
	Lock
	Temporary
)

func (ControlFileType) String added in v1.17.9

func (t ControlFileType) String() string

type ForcedUnlockError added in v1.6.0

type ForcedUnlockError struct {
	Errors []error
}

func (ForcedUnlockError) Error added in v1.6.0

func (e ForcedUnlockError) Error() string

type Handler added in v1.6.0

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

func NewHandlerForCreate added in v1.6.0

func NewHandlerForCreate(path string) (*Handler, error)

func NewHandlerForRead added in v1.6.0

func NewHandlerForRead(ctx context.Context, path string, defaultWaitTimeout time.Duration, retryDelay time.Duration) (*Handler, error)

func NewHandlerForUpdate added in v1.6.0

func NewHandlerForUpdate(ctx context.Context, path string, defaultWaitTimeout time.Duration, retryDelay time.Duration) (*Handler, error)

func NewHandlerWithoutLock added in v1.9.8

func NewHandlerWithoutLock(ctx context.Context, path string, defaultWaitTimeout time.Duration, retryDelay time.Duration) (*Handler, error)

func (*Handler) CreateControlFileContext added in v1.17.9

func (h *Handler) CreateControlFileContext(ctx context.Context, fileType ControlFileType, retryDelay time.Duration) error

func (*Handler) File added in v1.9.6

func (h *Handler) File() *os.File

func (*Handler) FileForUpdate added in v1.6.0

func (h *Handler) FileForUpdate() (*os.File, error)

func (*Handler) Path added in v1.6.0

func (h *Handler) Path() string

type IOError

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

func (IOError) Error

func (e IOError) Error() string

type LockError

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

func (LockError) Error

func (e LockError) Error() string

type NotExistError added in v1.9.8

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

func (NotExistError) Error added in v1.9.8

func (e NotExistError) Error() string

type OpenType added in v1.6.0

type OpenType int
const (
	ForRead OpenType = iota
	ForCreate
	ForUpdate
)

type Reader added in v1.17.9

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

func NewReader added in v1.17.9

func NewReader(r io.Reader, headLen int) (*Reader, error)

func (*Reader) HeadBytes added in v1.17.9

func (r *Reader) HeadBytes() (io.ReadSeeker, error)

func (*Reader) Read added in v1.17.9

func (r *Reader) Read(p []byte) (n int, err error)

func (*Reader) Size added in v1.17.9

func (r *Reader) Size() int64

type TimeoutError

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

func (TimeoutError) Error

func (e TimeoutError) Error() string

Jump to

Keyboard shortcuts

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