catalogflow

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package catalogflow handles the share descriptor and progressive LIST_CHILDREN. The sender can commit catalog payloads once because the protocol session authenticates delivery separately for each receiver.

Index

Constants

View Source
const (
	DefaultClientCacheBytes      = uint64(16) << 20
	DefaultClientDirectories     = 4_096
	MaxConcurrentDirectoryLoads  = 4
	DirectoryFailureMemoryBytes  = 128
	CatalogLeaseClaimMemoryBytes = 64
	// MaxClientLeaseClaims keeps 16,384 claims * 64 bytes within 1 MiB even
	// when the caller configures an effectively unbounded cache.
	MaxClientLeaseClaims = 16_384
	// MaxDirectoryLeaseClaims keeps 256 claims * 64 bytes within 16 KiB so a
	// hot directory cannot monopolize the global claim budget.
	MaxDirectoryLeaseClaims = 256
)
View Source
const (
	DirectoryCodeStale       uint16 = 0x2001
	DirectoryCodePermission  uint16 = 0x2002
	DirectoryCodeCollision   uint16 = 0x2003
	DirectoryCodeTooWide     uint16 = 0x2004
	DirectoryCodeBudget      uint16 = 0x2005
	DirectoryCodePermanentIO uint16 = 0x2006
	DirectoryCodeTransientIO uint16 = 0x2007
	DirectoryCodeCancelled   uint16 = 0x2008

	MinRetryAfter = 250 * time.Millisecond
	MaxRetryAfter = 30 * time.Second
)
View Source
const MaxListRequestBytes = 40

Variables

View Source
var (
	ErrWireObject       = errors.New("catalog wire object is invalid")
	ErrNonCanonicalWire = errors.New("catalog wire object is not canonical CBOR")
)
View Source
var (
	ErrInvalidRequest     = errors.New("catalog list request is invalid")
	ErrObjectIdentity     = errors.New("verified catalog object changes request identity")
	ErrPageGap            = errors.New("catalog page sequence contains a gap")
	ErrPageConflict       = errors.New("catalog page replay conflicts with committed content")
	ErrPostTerminal       = errors.New("catalog object arrived after the terminal page")
	ErrClientBudget       = errors.New("catalog client memory budget exceeded")
	ErrGenerationMismatch = errors.New("catalog request generation is stale")
	ErrPageOutOfRange     = errors.New("catalog request page is outside the generation")
	ErrUnverifiedObject   = errors.New("catalog verifier returned no page or failure")
	ErrResponseIdentity   = errors.New("verified catalog object does not answer its authenticated request")
)
View Source
var ErrCatalogCodec = errors.New("catalog flow payload is malformed")
View Source
var ErrClientClosed = errors.New("catalog client is closed")
View Source
var ErrPageCursorState = errors.New("catalog page cursor state is invalid")

Functions

func DecodeCatalogResult

func DecodeCatalogResult(encoded []byte) ([]byte, error)

func EncodeCatalogResult

func EncodeCatalogResult(payload []byte) ([]byte, error)

func EncodeDirectoryFailure

func EncodeDirectoryFailure(failure DirectoryFailure) ([]byte, error)

func EncodeListRequest

func EncodeListRequest(request ListRequest) ([]byte, error)

func SealDescriptor

func SealDescriptor(descriptor catalog.ShareDescriptor, config DescriptorObjectConfig) ([]byte, error)

Types

type AcceptStatus

type AcceptStatus uint8
const (
	PageAccepted AcceptStatus = iota + 1
	PageReplay
	GenerationCommitted
)

type AddressedSenderService

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

func NewAddressedSenderService

func NewAddressedSenderService(
	share catalog.ShareInstance,
	source PageAddressedSource,
) (*AddressedSenderService, error)

func (*AddressedSenderService) Serve

func (service *AddressedSenderService) Serve(
	ctx context.Context,
	request ListRequest,
	progress catalog.ScanProgressObserver,
) ([]byte, error)

type Assembler

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

func NewAssembler

func NewAssembler(instance catalog.ShareInstance, directory catalog.DirectoryID, maxPages uint32) (*Assembler, error)

func (*Assembler) Accept

func (a *Assembler) Accept(object VerifiedObject) (AcceptStatus, error)

func (*Assembler) NextRequest

func (a *Assembler) NextRequest() (ListRequest, error)

func (*Assembler) PageCount

func (a *Assembler) PageCount() int

func (*Assembler) Snapshot

func (a *Assembler) Snapshot() (catalog.DirectorySnapshot, bool)

type CatalogFailureEncoder added in v0.1.4

type CatalogFailureEncoder struct{}

func (CatalogFailureEncoder) EncodeFailure added in v0.1.4

type CatalogPayloadDecoder added in v0.1.4

type CatalogPayloadDecoder struct{}

CatalogPayloadDecoder checks the canonical record and its request binding after the session has authenticated delivery.

func (CatalogPayloadDecoder) Verify added in v0.1.4

type CatalogStoreSource

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

CatalogStoreSource preserves the page-addressed backend boundary. A later page never materializes its siblings, and only page zero without a generation may trigger the directory's share-scoped lazy scan.

func NewCatalogStoreSource

func NewCatalogStoreSource(config CatalogStoreSourceConfig) (*CatalogStoreSource, error)

func (*CatalogStoreSource) LoadPage

func (source *CatalogStoreSource) LoadPage(
	ctx context.Context,
	request ListRequest,
	progress catalog.ScanProgressObserver,
) (PageResult, error)

type CatalogStoreSourceConfig

type CatalogStoreSourceConfig struct {
	ShareInstance catalog.ShareInstance
	Store         *catalog.CatalogStore
	SessionBudget *catalog.BudgetAccount
	Scanner       catalog.DirectoryScanner
}

type Client

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

func NewClient

func NewClient(config ClientConfig) (*Client, error)

func (*Client) AcquireDirectory

func (c *Client) AcquireDirectory(
	ctx context.Context,
	directory catalog.DirectoryID,
) (catalog.DirectorySnapshot, func(), error)

AcquireDirectory pins the exact cached result delivered to this caller. The callback must be invoked even when err is a DirectoryFailure, and is safe to invoke more than once.

func (*Client) CachedBytes

func (c *Client) CachedBytes() uint64

func (*Client) Close

func (c *Client) Close()

Close is the owner-side join. Callbacks may invoke Stop, but must leave Close to their owner because joining from an owned callback would self-deadlock.

func (*Client) LoadDirectory

func (c *Client) LoadDirectory(ctx context.Context, directory catalog.DirectoryID) (catalog.DirectorySnapshot, error)

func (*Client) OpenDirectoryPages

func (c *Client) OpenDirectoryPages(
	ctx context.Context,
	directory catalog.DirectoryID,
) (catalog.DirectoryPageCursor, error)

OpenDirectoryPages creates a forward-only generation cursor. Unlike LoadDirectory, it verifies and releases each sender object before requesting the next page, so a protocol-wide directory never becomes one Go allocation.

func (*Client) ReleaseDirectory

func (c *Client) ReleaseDirectory(directory catalog.DirectoryID) bool

func (*Client) Snapshot

func (c *Client) Snapshot(directory catalog.DirectoryID) (catalog.DirectorySnapshot, bool)

func (*Client) Stop

func (c *Client) Stop()

Stop synchronously freezes admission and cancels every owned load without joining callbacks. This split lets a verifier or transport callback request shutdown without waiting for the goroutine that is currently invoking it.

type ClientConfig

type ClientConfig struct {
	ShareInstance           catalog.ShareInstance
	Transport               PageTransport
	Verifier                ObjectVerifier
	MaxPagesPerDirectory    uint32
	MaxObjectBytes          uint32
	MaxCacheBytes           uint64
	MaxDirectories          int
	MaxConcurrentLoads      int
	MaxLeaseClaims          int
	MaxDirectoryLeaseClaims int
	Now                     func() time.Time
}

type DescriptorObjectConfig

type DescriptorObjectConfig struct {
	PKHash           []byte
	ShareIDRaw       []byte
	DescriptorKey    []byte
	SenderPrivateKey ed25519.PrivateKey
	Nonce            []byte
}

type DirectoryFailure

type DirectoryFailure struct {
	ShareInstance catalog.ShareInstance
	DirectoryID   catalog.DirectoryID
	AttemptID     catalog.ScanAttemptID
	Code          uint16
	Retryable     bool
	RetryAfter    time.Duration
}

func DecodeDirectoryFailure

func DecodeDirectoryFailure(encoded []byte) (DirectoryFailure, error)

func NewDirectoryFailure

func NewDirectoryFailure(failure DirectoryFailure) (DirectoryFailure, error)

func (DirectoryFailure) DirectoryFailure

func (f DirectoryFailure) DirectoryFailure()

DirectoryFailure marks an authenticated, directory-scoped source failure. Consumers may skip only this subtree; unmarked verifier, identity, transport, and budget errors remain fatal to the consuming operation.

func (DirectoryFailure) Error

func (f DirectoryFailure) Error() string

type ListRequest

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

func DecodeListRequest

func DecodeListRequest(encoded []byte) (ListRequest, error)

func NewListRequest

func NewListRequest(directory catalog.DirectoryID, generation *catalog.DirectoryGeneration, pageIndex uint32) (ListRequest, error)

func (ListRequest) DirectoryID

func (r ListRequest) DirectoryID() catalog.DirectoryID

func (ListRequest) Generation

func (r ListRequest) Generation() (catalog.DirectoryGeneration, bool)

func (ListRequest) PageIndex

func (r ListRequest) PageIndex() uint32

type ObjectVerifier

type ObjectVerifier interface {
	Verify(context.Context, catalog.ShareInstance, ListRequest, []byte) (VerifiedObject, error)
}

ObjectVerifier decodes a payload and checks its request binding after the transport authenticates delivery.

type OpenedDescriptor

type OpenedDescriptor struct {
	Descriptor catalog.ShareDescriptor
	Sender     *senderauth.Verifier
}

OpenedDescriptor keeps the authenticated sender identity with the data it authenticated, so all receiver components can share its checked key.

func OpenDescriptor

func OpenDescriptor(object []byte, pkHash, shareIDRaw, descriptorKey []byte) (OpenedDescriptor, error)

type PageAddressedSource

type PageAddressedSource interface {
	LoadPage(context.Context, ListRequest, catalog.ScanProgressObserver) (PageResult, error)
}

type PageResult

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

func CatalogPageResult added in v0.1.4

func CatalogPageResult(page catalog.PagePayload) PageResult

CatalogPageResult exposes only payloads whose canonical bytes and address are bound.

type PageTransport

type PageTransport interface {
	FetchPage(context.Context, ListRequest) ([]byte, error)
}

type VerifiedObject

type VerifiedObject struct {
	Page    catalog.CatalogPage
	Failure *DirectoryFailure
}

func VerifiedFailure

func VerifiedFailure(failure DirectoryFailure) VerifiedObject

func VerifiedPage

func VerifiedPage(page catalog.CatalogPage) VerifiedObject

Jump to

Keyboard shortcuts

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