Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Initer ¶
type Initer interface {
Init()
}
Initer is optionally implemented by T to initialize zero-value fields (e.g., nil maps) after deserialization or when the backing store is empty.
type Store ¶
type Store[T any] interface { // With loads under lock and passes to fn; *T's Init() runs first if implemented; lock held for fn's duration. With(ctx context.Context, fn func(*T) error) error // Update performs a read-modify-write under lock. // If fn returns nil the data is persisted. Update(ctx context.Context, fn func(*T) error) error // ReadRaw deserializes the data and passes it to fn without acquiring the lock. // The caller must already hold the lock via TryLock. ReadRaw(fn func(*T) error) error // WriteRaw deserializes, runs fn, atomically persists; caller must hold the lock (via TryLock). WriteRaw(fn func(*T) error) error // TryLock non-blocking acquire; (false, nil) if held; on success caller must Unlock. TryLock(ctx context.Context) (bool, error) // Unlock releases a lock previously acquired by TryLock. Unlock(ctx context.Context) error }
Store provides locked read/modify/write access to a data store. T is the top-level structure managed by the store.
Click to show internal directories.
Click to hide internal directories.