Documentation
¶
Overview ¶
Package data implements bounded immutable-object HTTP transfers. Authentication is supplied by the cluster control layer; data checksums use XXH3-128 and are not cryptographic authentication of the body.
Index ¶
- Constants
- Variables
- func ObjectKey(d Descriptor) string
- func ReceiptBytes(r Receipt) []byte
- func ResponseProof(r *http.Request, op Operation, t Transfer, h http.Header, status int) []byte
- func SetTransfer(r *http.Request, t Transfer) error
- func TransferObject(t Transfer) cluster.ObjectScope
- func ValidateNamespaceID(id string) error
- func VerifyResponse(secret string, r *http.Response, op Operation, t Transfer) error
- type Client
- func (c *Client) Close()
- func (c *Client) DeleteObject(ctx context.Context, node Node, tr Transfer, condition DeleteCondition) error
- func (c *Client) Get(ctx context.Context, node Node, t Transfer) ([]byte, error)
- func (c *Client) Inventory(ctx context.Context, node Node, incarnation string, request InventoryRequest) (InventoryPage, error)
- func (c *Client) InventoryAt(ctx context.Context, node Node, incarnation string, request InventoryRequest) (InventoryPage, error)
- func (c *Client) Probe(ctx context.Context, node Node, t Transfer) (string, error)
- func (c *Client) Put(ctx context.Context, node Node, t Transfer, body io.Reader) (Receipt, error)
- func (c *Client) StatObject(ctx context.Context, node Node, tr Transfer) (ObjectInfo, error)
- type ClientConfig
- type DeleteCondition
- type Descriptor
- type ForwardConfig
- type Forwarder
- type InventoryPage
- type InventoryRequest
- type Node
- type ObjectInfo
- type Operation
- type Receipt
- type Server
- type ServerConfig
- type Stats
- type Transfer
Constants ¶
const ( Version = 1 ScopedVersion = 2 DefaultMaxObjectBytes int64 = 8 << 20 DefaultConcurrency = 16 TransferHeader = "X-Compactfs-Transfer" DescriptorHeader = "X-Compactfs-Descriptor" NodeHeader = "X-Compactfs-Node" StorageHeader = "X-Compactfs-Storage" )
const DefaultRequestTimeout = 2 * time.Minute
const DeleteConditionHeader = "X-Compactfs-Delete-Condition"
const ResponseSignatureHeader = "X-Cpfs-Response-Signature"
Variables ¶
var ( ErrInvalid = errors.New("invalid data request") ErrIntegrity = errors.New("data integrity check failed") ErrConflict = errors.New("immutable object conflict") ErrBusy = errors.New("data service capacity exhausted") )
var ErrProtected = errors.New("data object is protected or GC mark expired")
Functions ¶
func ObjectKey ¶
func ObjectKey(d Descriptor) string
func ReceiptBytes ¶
func ResponseProof ¶
ResponseProof binds headers to the exact requested representation and attempt. Bulk bytes are checked separately using XXH3, avoiding an additional HMAC pass.
func TransferObject ¶
func TransferObject(t Transfer) cluster.ObjectScope
func ValidateNamespaceID ¶
ValidateNamespaceID accepts an opaque bounded identity, never a filesystem path. Empty identifies the legacy default namespace.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client owns its default HTTP transport. Caller-provided clients are borrowed. Get returns verified, owned bytes, never an unverified live network reader.
func NewClient ¶
func NewClient(cfg ClientConfig) (*Client, error)
func (*Client) DeleteObject ¶
func (*Client) Get ¶
Get races at most two endpoints belonging to one node. It cancels the losing request immediately after selecting legal headers. If the winner's body fails integrity, the canceled alternative is retried once sequentially.
func (*Client) Inventory ¶
func (c *Client) Inventory(ctx context.Context, node Node, incarnation string, request InventoryRequest) (InventoryPage, error)
Inventory requires the expected persistent disk incarnation, never merely a NodeID which could have been reassigned to an empty replacement disk.
func (*Client) InventoryAt ¶
func (c *Client) InventoryAt(ctx context.Context, node Node, incarnation string, request InventoryRequest) (InventoryPage, error)
InventoryAt is the explicit-incarnation spelling of Inventory.
func (*Client) Probe ¶
Probe chooses the first authenticated write endpoint among at most two approved addresses. It sends signed HEAD requests with no object body or storage mutation. It does not retry a PUT; the caller subsequently performs exactly one upload to the returned endpoint using its original transfer.
func (*Client) Put ¶
Put deliberately chooses only the first endpoint. A failed/uncertain PUT is resolved by the caller using its original upload/attempt, never raced here.
func (*Client) StatObject ¶
type ClientConfig ¶
type DeleteCondition ¶
type Descriptor ¶
type Descriptor struct {
Version int `json:"version"`
NamespaceID string `json:"namespace_id,omitempty"`
ObjectID string `json:"object_id"`
RawHash string `json:"raw_hash"`
RawSize int64 `json:"raw_size"`
Codec string `json:"codec"`
WireVersion int `json:"wire_version"`
EncodedHash string `json:"encoded_hash"`
EncodedSize int64 `json:"encoded_size"`
}
Descriptor identifies an exact encoded representation independently of its replica node or upload attempt. RawHash remains the existing content ID.
func NewDescriptor ¶
func NewScopedDescriptor ¶
func NewScopedDescriptor(namespaceID, rawHash string, rawSize int64, codec string, encoded []byte) (Descriptor, error)
NewScopedDescriptor binds identical encoded bytes to a namespace-specific immutable object identity. Empty namespace preserves the original v1 ID.
func (Descriptor) ID ¶
func (d Descriptor) ID() string
ID excludes ObjectID itself and all transport/upload identities.
func (Descriptor) Validate ¶
func (d Descriptor) Validate(max int64) error
type ForwardConfig ¶
type Forwarder ¶
type Forwarder struct {
// contains filtered or unexported fields
}
Forwarder forwards opaque signed requests without taking ownership of credentials or file publication. It has a separate bounded connection pool.
func NewForwarder ¶
func NewForwarder(cfg ForwardConfig) (*Forwarder, error)
type InventoryPage ¶
type InventoryPage struct {
Epoch string `json:"epoch"`
Before time.Time `json:"before"`
Next string `json:"next,omitempty"`
Objects []ObjectInfo `json:"objects"`
}
type InventoryRequest ¶
type ObjectInfo ¶
type ObjectInfo struct {
Descriptor Descriptor `json:"descriptor"`
DurableAt time.Time `json:"durable_at"`
ProtectedUntil time.Time `json:"protected_until"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server does not own its Backend. Each active transfer owns one bounded buffer and PUT owns one temporary file, deleted before the handler returns.
func NewServer ¶
func NewServer(cfg ServerConfig) (*Server, error)
func (*Server) Close ¶
Close releases the optional catalog. The listener owner must first stop and join its HTTP handlers; Server never closes the borrowed object backend.
func (*Server) RegisterObject ¶
RegisterObject imports an exact preexisting immutable representation into the maintenance catalog. The caller must hold exclusive initialization; the object is protected for a fresh lease and is never immediately collectible.
type ServerConfig ¶
type ServerConfig struct {
NodeID string
StorageIncarnation string
Backend backend.Backend
StagingDir string
MaxObjectBytes int64
MaxConcurrent int
// RequestTimeout bounds guard/lock admission, body I/O and response flush.
// Zero uses DefaultRequestTimeout; callers may choose a larger bound.
RequestTimeout time.Duration
Authorize func(*http.Request, Operation, Transfer) error
SignReceipt func(Receipt) (string, error)
SignResponse func(*http.Request, Operation, Transfer, http.Header) error
// MaintenancePath enables a durable object catalog and authenticated GC.
// Caller must stop HTTP handlers before Close. Empty disables management.
MaintenancePath string
ProtectionTTL time.Duration
MinGCAge time.Duration
Gate func(context.Context) error
// Guard owns admission through the complete response, including ordinary
// transfers and maintenance. Updates take its corresponding write lock.
Guard func(context.Context, func() error) error
}