Documentation
¶
Overview ¶
Package catalogflow provides the progressive LIST_CHILDREN service and client above an authenticated protocol session. It never reads a FrameChannel and never interprets local paths; transport and sender-object authentication are injected at its two narrow boundaries.
Index ¶
- Constants
- Variables
- func DecodeCatalogResult(encoded []byte) ([]byte, error)
- func EncodeCatalogResult(object []byte) ([]byte, error)
- func EncodeDirectoryFailure(failure DirectoryFailure) ([]byte, error)
- func EncodeListRequest(request ListRequest) ([]byte, error)
- func SealDescriptor(descriptor catalog.ShareDescriptor, config DescriptorObjectConfig) ([]byte, error)
- type AcceptStatus
- type AddressedSenderService
- type Assembler
- type CatalogObjectVerifier
- type CatalogObjectVerifierConfig
- type CatalogStoreSource
- type CatalogStoreSourceConfig
- type Client
- func (c *Client) AcquireDirectory(ctx context.Context, directory catalog.DirectoryID) (catalog.DirectorySnapshot, func(), error)
- func (c *Client) CachedBytes() uint64
- func (c *Client) Close()
- func (c *Client) LoadDirectory(ctx context.Context, directory catalog.DirectoryID) (catalog.DirectorySnapshot, error)
- func (c *Client) OpenDirectoryPages(ctx context.Context, directory catalog.DirectoryID) (catalog.DirectoryPageCursor, error)
- func (c *Client) ReleaseDirectory(directory catalog.DirectoryID) bool
- func (c *Client) Snapshot(directory catalog.DirectoryID) (catalog.DirectorySnapshot, bool)
- func (c *Client) Stop()
- type ClientConfig
- type DescriptorObjectConfig
- type DirectoryFailure
- type DirectoryResult
- type DirectorySource
- type ListRequest
- type ObjectVerifier
- type OpenedDescriptor
- type PageAddressedSource
- type PageResult
- type PageTransport
- type SealedCatalogStore
- func (store *SealedCatalogStore) Destroy()
- func (store *SealedCatalogStore) LoadSealedFailure(ctx context.Context, failure DirectoryFailure) ([]byte, error)
- func (store *SealedCatalogStore) LoadSealedPage(ctx context.Context, page catalog.CatalogPage) ([]byte, error)
- func (store *SealedCatalogStore) Seal(input catalog.PageCommitInput) (catalog.SealedPageObject, error)
- func (store *SealedCatalogStore) SealFailure(record catalog.DirectoryFailureRecord) (catalog.SealedFailureObject, error)
- func (store *SealedCatalogStore) Stop()
- type SealedCatalogStoreConfig
- type SealedObjectStore
- type SenderService
- type VerifiedObject
Constants ¶
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 )
const ( DefaultPageObjectCacheBytes = uint64(1) << 20 DefaultFailureObjectBytes = uint64(16) << 20 )
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 )
const MaxListRequestBytes = 40
Variables ¶
var ( ErrCatalogObjectConflict = errors.New("catalog sender object identity already has different content") ErrCatalogObjectMissing = errors.New("catalog sender object is not committed") ErrSealedCatalogStoreDestroyed = errors.New("sealed catalog store was destroyed") ErrCatalogObjectVerifierDestroyed = errors.New("catalog object verifier was destroyed") )
var ( ErrWireObject = errors.New("catalog wire object is invalid") ErrNonCanonicalWire = errors.New("catalog wire object is not canonical CBOR") )
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") )
var ErrCatalogCodec = errors.New("catalog flow object is malformed")
var ErrClientClosed = errors.New("catalog client is closed")
var ErrPageCursorState = errors.New("catalog page cursor state is invalid")
Functions ¶
func DecodeCatalogResult ¶
func EncodeCatalogResult ¶
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)
type CatalogObjectVerifier ¶
type CatalogObjectVerifier struct {
// contains filtered or unexported fields
}
CatalogObjectVerifier owns its catalog secret and shares immutable sender verification state. Teardown must not invalidate other receiver components.
func NewCatalogObjectVerifier ¶
func NewCatalogObjectVerifier(config CatalogObjectVerifierConfig) (*CatalogObjectVerifier, error)
func (*CatalogObjectVerifier) Destroy ¶
func (verifier *CatalogObjectVerifier) Destroy()
Destroy waits for admitted verification to finish before erasing keys, so concurrent authentication never observes partially cleared authority.
func (*CatalogObjectVerifier) Stop ¶
func (verifier *CatalogObjectVerifier) Stop()
Stop closes verifier admission without waiting for already-authenticated objects to finish decoding.
func (*CatalogObjectVerifier) Verify ¶
func (verifier *CatalogObjectVerifier) Verify( ctx context.Context, share catalog.ShareInstance, request ListRequest, object []byte, ) (VerifiedObject, error)
type CatalogObjectVerifierConfig ¶
type CatalogObjectVerifierConfig struct {
CatalogKey []byte
Sender *senderauth.Verifier
}
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 {
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 (*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)
type ClientConfig ¶
type DescriptorObjectConfig ¶
type DescriptorObjectConfig struct {
PKHash []byte
DescriptorKey []byte
SenderPrivateKey ed25519.PrivateKey
Nonce []byte
}
type DirectoryFailure ¶
type DirectoryFailure struct {
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 DirectoryResult ¶
type DirectoryResult struct {
Snapshot catalog.DirectorySnapshot
Failure *DirectoryFailure
}
func FailureResult ¶
func FailureResult(failure DirectoryFailure) DirectoryResult
func SnapshotResult ¶
func SnapshotResult(snapshot catalog.DirectorySnapshot) DirectoryResult
type DirectorySource ¶
type DirectorySource interface {
LoadDirectory(ctx context.Context, directory catalog.DirectoryID) (DirectoryResult, error)
}
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)
}
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 {
Page catalog.CatalogPage
SealedObject []byte
Failure *DirectoryFailure
}
type PageTransport ¶
type PageTransport interface {
FetchPage(context.Context, ListRequest) ([]byte, error)
}
type SealedCatalogStore ¶
type SealedCatalogStore struct {
// contains filtered or unexported fields
}
SealedCatalogStore owns cloned catalog/signing keys and a bounded read-through cache; CatalogStore's backend remains the authority for committed page bytes. Keeping the roles separate prevents random-nonce objects from becoming RAM-only state and gives Destroy one precise secret owner.
func NewSealedCatalogStore ¶
func NewSealedCatalogStore(config SealedCatalogStoreConfig) (*SealedCatalogStore, error)
func (*SealedCatalogStore) Destroy ¶
func (store *SealedCatalogStore) Destroy()
Destroy is owner-only and must not run from NonceSource.Read because it waits for every operation admitted before Stop to release its cryptographic inputs.
func (*SealedCatalogStore) LoadSealedFailure ¶
func (store *SealedCatalogStore) LoadSealedFailure(ctx context.Context, failure DirectoryFailure) ([]byte, error)
func (*SealedCatalogStore) LoadSealedPage ¶
func (store *SealedCatalogStore) LoadSealedPage(ctx context.Context, page catalog.CatalogPage) ([]byte, error)
func (*SealedCatalogStore) Seal ¶
func (store *SealedCatalogStore) Seal(input catalog.PageCommitInput) (catalog.SealedPageObject, error)
func (*SealedCatalogStore) SealFailure ¶
func (store *SealedCatalogStore) SealFailure(record catalog.DirectoryFailureRecord) (catalog.SealedFailureObject, error)
func (*SealedCatalogStore) Stop ¶
func (store *SealedCatalogStore) Stop()
Stop is safe inside NonceSource.Read: it rejects new work without waiting for the operation that owns the callback.
type SealedObjectStore ¶
type SealedObjectStore interface {
LoadSealedPage(context.Context, catalog.CatalogPage) ([]byte, error)
LoadSealedFailure(context.Context, DirectoryFailure) ([]byte, error)
}
SealedObjectStore returns the exact bytes committed for an immutable page or scan attempt. Catalog chaining hashes complete sender-object bytes, so serving code must never reseal on demand with a new nonce.
type SenderService ¶
type SenderService struct {
// contains filtered or unexported fields
}
func NewSenderService ¶
func NewSenderService(instance catalog.ShareInstance, source DirectorySource, objects SealedObjectStore) (*SenderService, error)
func (*SenderService) Serve ¶
func (s *SenderService) Serve(ctx context.Context, request 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