file

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package file provides a local JSON-backed session store for Glue.

It writes one file per session below a configured directory using atomic temp-file-plus-rename writes, and implements the glue.Store interface. It is the simple default with no extra dependencies; reach for stores/sqlite when you need cross-session search.

Package file provides a local JSON-backed session store for Glue.

Each session is written to <dir>/<url-escaped-id>.json. Saves are atomic: the JSON payload is first written to a sibling temp file in the same directory and then os.Rename'd into place, so concurrent readers either see the previous file or the new file but never a partial write.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store persists Glue sessions as local JSON files.

func New

func New(dir string) *Store

New creates a file-backed store rooted at dir. The directory is created on first save; calling New does not touch the filesystem.

func (*Store) Delete

func (s *Store) Delete(_ context.Context, id string) error

Delete removes a session state. Missing sessions are a no-op success.

func (*Store) ListSessions

func (s *Store) ListSessions(ctx context.Context, opts glue.ListSessionsOptions) ([]glue.SessionSummary, error)

ListSessions implements glue.SessionLister by scanning JSON session files.

func (*Store) Load

func (s *Store) Load(_ context.Context, id string) (glue.SessionState, bool, error)

Load reads a session state. Missing sessions return found=false with no error.

func (*Store) Path

func (s *Store) Path(id string) (string, error)

Path returns the JSON file path for a session id. It is exposed for tests and debugging; production code should not rely on it.

func (*Store) Save

func (s *Store) Save(_ context.Context, id string, state glue.SessionState) error

Save writes a session state atomically.

Jump to

Keyboard shortcuts

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