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
- Variables
- func DecodeCatalogResult(encoded []byte) ([]byte, error)
- func EncodeCatalogResult(payload []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 CatalogFailureEncoder
- type CatalogPayloadDecoder
- 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 ListRequest
- type ObjectVerifier
- type OpenedDescriptor
- type PageAddressedSource
- type PageResult
- type PageTransport
- 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 ( 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 ( 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 payload 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 CatalogFailureEncoder ¶ added in v0.1.4
type CatalogFailureEncoder struct{}
func (CatalogFailureEncoder) EncodeFailure ¶ added in v0.1.4
func (CatalogFailureEncoder) EncodeFailure(record catalog.DirectoryFailureRecord) (catalog.FailurePayload, error)
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
func (CatalogPayloadDecoder) Verify(ctx context.Context, share catalog.ShareInstance, request ListRequest, payload []byte) (VerifiedObject, error)
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 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