profilestore

package
v0.1.45 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Read hooks: the contract a data source implements to prepare profile reads, and the errors it wraps so the transport answers with the right status.

Package profilestore holds the contracts a profile store and a profile read hook satisfy, shared by the profile service and the data sources it serves.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrProfileDataNotFound is what a BeforeExecuteFunc wraps when the data a
	// request names does not exist, so the transport answers 404 rather than
	// an empty result that reads as "nothing matched".
	ErrProfileDataNotFound = errors.New("profile data not found")

	// ErrProfileRequestInvalid is what a BeforeExecuteFunc wraps when the
	// request itself cannot be served — a param missing or malformed — so the
	// transport answers 400. Every failure it does not wrap is the server's.
	ErrProfileRequestInvalid = errors.New("profile request invalid")

	// ErrProfileForbidden is what a BeforeExecuteFunc wraps when the request
	// names data the caller may not read, so the transport answers 403.
	ErrProfileForbidden = errors.New("profile data forbidden")
)

Functions

func PrepareReads

func PrepareReads(ctx context.Context, hook BeforeExecuteFunc, reads []ReadRequest) (func(), error)

PrepareReads runs hook and normalises its cleanup contract. A hook that acquired resources before failing still gets its release called; a successful caller always gets a non-nil, exactly-once cleanup.

Types

type BeforeExecuteFunc

type BeforeExecuteFunc func(ctx context.Context, reads []ReadRequest) (release func(), err error)

BeforeExecuteFunc prepares one or more profile reads and returns the release that keeps their data readable. The caller holds release until every read in the batch has finished. Its error fails the whole batch; nothing is read after it.

It is the seam a data source that has to be prepared per request plugs into — a record stream index caught up to its source before the index is paged. A hook may rewrite a read's Params (see ReadRequest), and must leave a map it already rewrote as it is when it prepares that map again.

type ReadRequest

type ReadRequest struct {
	Profile query.Profile
	Params  map[string]any
}

ReadRequest is one resolved profile read and the parameters the caller supplied, unresolved. Params is the map the caller executes the read with, and a hook may rewrite it in place: a data source that indexes what a caller names under another id — a routed record stream — binds that id, which only the hook, running under the request's context, can resolve.

type UpdateOptions

type UpdateOptions struct {
	ReplaceExisting bool
}

type VirtualStore

type VirtualStore interface {
	Store
	Peek(context.Context, string) (query.Profile, error)
	IsVirtual(string) bool
}

Jump to

Keyboard shortcuts

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