json

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any](filePath string, locker lock.Locker) *Store[T]

New creates a JSON file-backed store with the given lock.

func (*Store[T]) ReadRaw

func (s *Store[T]) ReadRaw(fn func(*T) error) error

ReadRaw loads the JSON file and passes the decoded data to fn without locking.

func (*Store[T]) TryLock

func (s *Store[T]) TryLock(ctx context.Context) (bool, error)

TryLock attempts to acquire the store lock without blocking.

func (*Store[T]) Unlock

func (s *Store[T]) Unlock(ctx context.Context) error

Unlock releases the store lock.

func (*Store[T]) Update

func (s *Store[T]) Update(ctx context.Context, fn func(*T) error) error

Update acquires the lock, loads, mutates via fn, and atomically writes back.

func (*Store[T]) With

func (s *Store[T]) With(ctx context.Context, fn func(*T) error) error

With acquires the lock, loads the data, and passes it to fn read-only.

func (*Store[T]) WriteRaw

func (s *Store[T]) WriteRaw(fn func(*T) error) error

WriteRaw loads, mutates via fn, and atomically writes back without locking.

Jump to

Keyboard shortcuts

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