json

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 7 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]

func (*Store[T]) ReadRaw

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

ReadRaw loads the JSON file unlocked.

func (*Store[T]) TryLock

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

func (*Store[T]) Unlock

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

func (*Store[T]) Update

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

Update runs fn read-modify-write under the store lock.

func (*Store[T]) With

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

With runs fn read-only under the store lock.

func (*Store[T]) WriteRaw

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

WriteRaw loads, mutates, atomically writes back — unlocked.

Jump to

Keyboard shortcuts

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