flatfile

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package flatfile decodes strict bounded versioned datasource documents into immutable in-memory snapshots.

On Linux and macOS the provider duplicates and owns a caller-opened directory descriptor, validates root and file metadata, and reads one no-follow file descriptor relative to that confined root. Reload publishes a complete generation atomically. A failed reload retains the prior snapshot only for recovery and makes later resolves unavailable until an explicit successful reload. The package never resolves paths from record values, exposes private keys, serves degraded state, or runs background reload work.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

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

Provider owns one confined root capability and atomically reloadable snapshot.

func New

func New(
	rootFD int,
	filename string,
	limits datasource.Limits,
) (*Provider, error)

New constructs one production confined provider from a borrowed root descriptor.

func (*Provider) Close

func (p *Provider) Close(ctx context.Context) (resultErr error)

Close publishes closed state before one non-retried owned-root close.

func (*Provider) Format

func (p *Provider) Format(state fmt.State, _ rune)

Format prevents formatting verbs from exposing capability or file facts.

func (*Provider) GoString

func (p *Provider) GoString() string

GoString returns a constant protected provider representation.

func (*Provider) MarshalJSON

func (p *Provider) MarshalJSON() ([]byte, error)

MarshalJSON emits an empty object so provider internals cannot be serialized.

func (*Provider) Reload

func (p *Provider) Reload(ctx context.Context) (resultErr error)

Reload serializes one explicit load and atomically publishes success or degradation.

func (*Provider) ResolvePolicy

func (p *Provider) ResolvePolicy(
	ctx context.Context,
	request datasource.PolicyRequest,
) (datasource.ResolvedPolicy, error)

ResolvePolicy resolves against the one lifecycle snapshot captured at linearization.

func (*Provider) ResolveProfile

func (p *Provider) ResolveProfile(
	ctx context.Context,
	request datasource.ProfileRequest,
) (datasource.ResolvedProfile, error)

ResolveProfile resolves against the one lifecycle snapshot captured at linearization.

func (*Provider) State

func (p *Provider) State() (datasource.ProviderState, error)

State returns the bounded lifecycle state without exposing generation or records.

func (*Provider) String

func (p *Provider) String() string

String returns a constant protected provider summary.

func (*Provider) Usage

func (p *Provider) Usage() (datasource.Usage, error)

Usage returns bounded accounting retained for ready or degraded diagnosis.

type Snapshot

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

Snapshot owns one immutable decoded provider and its parser accounting.

func Decode

func Decode(
	generation uint64,
	document []byte,
	limits datasource.Limits,
) (*Snapshot, error)

Decode validates one complete byte document into an immutable snapshot.

func DecodeReader

func DecodeReader(
	generation uint64,
	reader io.Reader,
	limits datasource.Limits,
) (snapshot *Snapshot, resultErr error)

DecodeReader reads at most one byte beyond the file cap before decoding.

func (*Snapshot) Format

func (s *Snapshot) Format(state fmt.State, _ rune)

Format prevents formatting verbs from exposing decoded provider facts.

func (*Snapshot) GoString

func (s *Snapshot) GoString() string

GoString returns a constant protected snapshot representation.

func (*Snapshot) InspectPolicy

func (s *Snapshot) InspectPolicy(
	ctx context.Context,
	request datasource.PolicyRequest,
) (datasource.ResolvedPolicy, error)

InspectPolicy delegates exact inert binding inspection after the same immutable-snapshot and parser-accounting checks as runtime resolution.

func (*Snapshot) MarshalJSON

func (s *Snapshot) MarshalJSON() ([]byte, error)

MarshalJSON emits an empty object so decoded facts cannot be serialized.

func (*Snapshot) ResolvePolicy

func (s *Snapshot) ResolvePolicy(
	ctx context.Context,
	request datasource.PolicyRequest,
) (datasource.ResolvedPolicy, error)

ResolvePolicy delegates one exact lookup to the immutable decoded provider.

func (*Snapshot) ResolveProfile

func (s *Snapshot) ResolveProfile(
	ctx context.Context,
	request datasource.ProfileRequest,
) (datasource.ResolvedProfile, error)

ResolveProfile delegates one exact lookup to the immutable decoded provider.

func (*Snapshot) String

func (s *Snapshot) String() string

String returns a constant protected snapshot summary.

func (*Snapshot) Usage

func (s *Snapshot) Usage() (datasource.Usage, error)

Usage returns bounded counts and aggregate decoded JSON string bytes.

func (*Snapshot) Valid

func (s *Snapshot) Valid() bool

Valid reports whether the decoded snapshot and accounting remain consistent.

Jump to

Keyboard shortcuts

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