filestream

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package filestream provides bounded byte transport shared by native file readers and producers that serialize records incrementally.

Index

Constants

View Source
const (
	ChunkBytes       = 1024 * 1024
	MaxRetainedBytes = int64(1<<31-1) * ChunkBytes
)

Variables

View Source
var ErrUnavailable = xerror.ExecutionUnavailable().WithPublicDetail("Retained file input is unavailable, expired or invalid; recovery cannot proceed.")

Functions

func ParseReference

func ParseReference(ref filepayload.Reference, maxBytes int64) (uuid.UUID, error)

ParseReference validates the transport shape and effective file allowance. Database capabilities separately check ownership, retention and live claims.

func WithStore

func WithStore(ctx context.Context, store Store) context.Context

Types

type Claim

type Claim struct {
	RequestID    uuid.UUID
	ClaimToken   uuid.UUID
	Organization slug.Slug
}

Claim scopes retained input access to one live execution request.

type Manifest

type Manifest struct {
	SizeBytes  int64
	ChunkCount int32
	SHA256     string
	ExpiresAt  time.Time
}

Manifest is readable only after successful source consumption and sealing.

type Metadata

type Metadata struct {
	SizeBytes   int64
	SHA256      string
	ContentType string
}

Metadata describes fully consumed bytes. It never contains the file body.

func Copy

func Copy(ctx context.Context, dst io.Writer, src io.Reader, maxBytes int64) (*Metadata, error)

Copy applies synchronous backpressure and never writes beyond maxBytes. Any error invalidates the partial destination; callers must not publish it. Readers and writers must honor their operation context while blocked in I/O.

type Producer

type Producer func(io.Writer) (*Metadata, error)

Producer writes one complete finite file into retained storage.

type Store

Store is the connector-neutral retained-input boundary. References belong only in encrypted broker traffic and process-local payloads.

func FromContext

func FromContext(ctx context.Context) (Store, bool)

type VerifiedReader

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

VerifiedReader withholds the final read until exact length, EOF and digest agree. Providers must not publish partial input after any read error.

func NewVerifiedReader

func NewVerifiedReader(ctx context.Context, src io.Reader, size int64, digest string) (*VerifiedReader, error)

func (*VerifiedReader) Complete

func (r *VerifiedReader) Complete() bool

Complete reports whether exact length, EOF and digest have been verified.

func (*VerifiedReader) Read

func (r *VerifiedReader) Read(p []byte) (int, error)

Jump to

Keyboard shortcuts

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