memorylocker

package
v2.0.0-...-a21236f Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package memorylocker provides an in-memory locking mechanism.

When multiple processes are attempting to access an upload, whether it be by reading or writing, a synchronization mechanism is required to prevent data corruption, especially to ensure correct offset values and the proper order of chunks inside a single upload.

MemoryLocker persists locks using memory and therefore allowing a simple and cheap mechanism. Locks will only exist as long as this object is kept in reference and will be erased if the program exits.

If somebody tries to acquire a lock that is already held, the `requestRelease` callback will be invoked that was provided when the lock was successfully acquired the first time. The lock holder should then cease its operation and release the lock properly, so somebody else can acquire it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryLocker

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

MemoryLocker persists locks using memory and therefore allowing a simple and cheap mechanism. Locks will only exist as long as this object is kept in reference and will be erased if the program exits.

func New

func New() *MemoryLocker

New creates a new in-memory locker.

func (*MemoryLocker) NewLock

func (locker *MemoryLocker) NewLock(id string) (handler.Lock, error)

func (*MemoryLocker) UseIn

func (locker *MemoryLocker) UseIn(composer *handler.StoreComposer)

UseIn adds this locker to the passed composer.

Jump to

Keyboard shortcuts

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