capturestore

package
v0.141.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 24 Imported by: 0 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 capturestore provides a bounded client for the fleet capture-store API. It supports authenticated binary ingestion, scoped capture queries, and checksum-verified retrieval of stored response bodies.

Index

Constants

View Source
const (
	MaxBodyBytes     = 8 << 20
	MaxMetadataBytes = 16 << 10
	DefaultTimeout   = 5 * time.Second
)
View Source
const (
	MaxDerivationBatchItems = 24
	MaxDerivationBatchBytes = 8 << 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BodyResult

type BodyResult struct {
	Body          io.ReadCloser
	SHA256        string
	ContentLength int64
}

BodyResult is a gzip stream and its uncompressed SHA-256 checksum.

type Capture

type Capture struct {
	ID string `json:"id"`
	Metadata
	BodyBytes int64  `json:"body_bytes"`
	SHA256    string `json:"sha256"`
	GzipBytes int64  `json:"gzip_bytes"`
	CreatedAt string `json:"created_at"`
}

type CaptureWrite added in v0.140.4

type CaptureWrite struct {
	Metadata Metadata
	Body     []byte
	SHA256   string
}

CaptureWrite binds already-hashed raw bytes to their capture metadata.

type CaptureWriteResult added in v0.140.4

type CaptureWriteResult struct {
	Result CreateResult
	Err    error
}

type Client

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

func New

func New(cfg Config) (*Client, error)

func (*Client) Compare

func (c *Client) Compare(ctx context.Context, left, right string) (Comparison, error)

func (*Client) Create

func (c *Client) Create(ctx context.Context, m Metadata, body []byte) (CreateResult, error)

func (*Client) CreateBatch added in v0.140.4

func (c *Client) CreateBatch(ctx context.Context, pages []CaptureWrite) ([]CaptureWriteResult, error)

func (*Client) CreateDerivation added in v0.134.6

func (c *Client) CreateDerivation(ctx context.Context, captureID string, m DerivationMetadata, body json.RawMessage) (DerivationResult, error)

func (*Client) CreateDerivationBatch added in v0.135.1

func (c *Client) CreateDerivationBatch(ctx context.Context, captureID string, items []DerivationWrite) ([]DerivationResult, error)

CreateDerivationBatch commits results for one capture and returns one checksum-verified receipt per input in request order.

func (*Client) CreateMultiCaptureDerivations added in v0.140.4

func (c *Client) CreateMultiCaptureDerivations(ctx context.Context, groups []DerivationGroup, raw bool) ([]DerivationGroupResult, error)

func (*Client) CreateRawDerivationBatch added in v0.140.4

func (c *Client) CreateRawDerivationBatch(ctx context.Context, captureID string, items []DerivationWrite) ([]DerivationResult, error)

CreateRawDerivationBatch commits the same group as CreateDerivationBatch while sending each parser output's exact bytes in its own MIME part.

func (*Client) CreateWithDigest added in v0.140.4

func (c *Client) CreateWithDigest(ctx context.Context, m Metadata, body []byte, digest string) (CreateResult, error)

CreateWithDigest carries a SHA-256 already computed over these immutable bytes. The service verifies it independently and the receipt must agree.

func (*Client) DerivationBody added in v0.134.6

func (c *Client) DerivationBody(ctx context.Context, d Derivation) (json.RawMessage, error)

DerivationBody verifies both the response checksum and the previously read immutable metadata. The JSON is data; callers must never render it as HTML.

func (*Client) Download

func (c *Client) Download(ctx context.Context, id string) ([]byte, error)

func (*Client) DownloadCapture added in v0.140.4

func (c *Client) DownloadCapture(ctx context.Context, capture Capture) ([]byte, error)

DownloadCapture verifies the downloaded body against its previously read index metadata in the same pass as verifying the download receipt.

func (*Client) Get

func (c *Client) Get(ctx context.Context, id string) (Capture, error)

func (*Client) GetDerivation added in v0.134.6

func (c *Client) GetDerivation(ctx context.Context, id string) (Derivation, error)

func (*Client) List

func (c *Client) List(ctx context.Context, o ListOptions) (ListResult, error)

func (*Client) ListDerivations added in v0.134.6

func (c *Client) ListDerivations(ctx context.Context, o DerivationListOptions) (DerivationList, error)

func (*Client) OpenBody

func (c *Client) OpenBody(ctx context.Context, id string) (BodyResult, error)

func (*Client) Storage

func (c *Client) Storage(ctx context.Context) (Storage, error)

type Comparison

type Comparison struct {
	Left           Capture   `json:"left"`
	Right          Capture   `json:"right"`
	SameBody       bool      `json:"same_body"`
	BodyBytesDelta int64     `json:"body_bytes_delta"`
	LatencyMSDelta int64     `json:"latency_ms_delta"`
	Text           *TextDiff `json:"text,omitempty"`
}

type Config

type Config struct {
	URL, Token, TokenFile string
	Timeout               time.Duration
	Transport             http.RoundTripper
}

Config identifies a capture-store HTTPS origin and a scoped service credential. Transport is intended for tests and does not relax URL validation.

type CreateResult

type CreateResult struct {
	Capture Capture `json:"capture"`
	Reused  bool    `json:"reused"`
}

type Derivation added in v0.134.6

type Derivation struct {
	ID string `json:"id"`
	DerivationMetadata
	CaptureID string `json:"capture_id"`
	Namespace string `json:"namespace"`
	URL       string `json:"url"`
	SHA256    string `json:"sha256"`
	BodyBytes int64  `json:"body_bytes"`
	GzipBytes int64  `json:"gzip_bytes"`
	CreatedAt string `json:"created_at"`
}

type DerivationBatch added in v0.135.1

type DerivationBatch struct {
	Items []DerivationWrite `json:"items"`
}

type DerivationGroup added in v0.140.4

type DerivationGroup struct {
	CaptureID string
	Items     []DerivationWrite
}

type DerivationGroupResult added in v0.140.4

type DerivationGroupResult struct {
	Results []DerivationResult
	Err     error
}

type DerivationList added in v0.134.6

type DerivationList struct {
	Derivations []Derivation `json:"derivations"`
	Total       int64        `json:"total"`
	Limit       int          `json:"limit"`
	Offset      int          `json:"offset"`
}

type DerivationListOptions added in v0.134.6

type DerivationListOptions struct {
	Namespace, Domain, CaptureID, ParserID string
	Limit, Offset                          int
}

type DerivationMetadata added in v0.134.6

type DerivationMetadata struct {
	IdempotencyKey string `json:"idempotency_key"`
	InputSHA256    string `json:"input_sha256"`
	ParserID       string `json:"parser_id"`
	ParserVersion  string `json:"parser_version"`
	OptionsSHA256  string `json:"options_sha256"`
	Status         string `json:"status"`
}

DerivationMetadata binds one immutable parser result to the exact source bytes.

type DerivationResult added in v0.134.6

type DerivationResult struct {
	Derivation Derivation `json:"derivation"`
	Reused     bool       `json:"reused"`
}

type DerivationWrite added in v0.135.1

type DerivationWrite struct {
	Metadata DerivationMetadata `json:"metadata"`
	Body     []byte             `json:"body"`
}

DerivationWrite keeps the exact owner response bytes. The JSON wire format uses base64 rather than re-encoding the parser's JSON object.

type ListOptions

type ListOptions struct {
	Namespace, Domain, Provider, Account, Pool, Class, SourceService, Status string
	Limit, Offset                                                            int
}

type ListResult

type ListResult struct {
	Captures []Capture `json:"captures"`
	Total    int64     `json:"total"`
	Limit    int       `json:"limit"`
	Offset   int       `json:"offset"`
}

type Metadata

type Metadata struct {
	IdempotencyKey string            `json:"idempotency_key"`
	Namespace      string            `json:"namespace"`
	SourceService  string            `json:"source_service"`
	SourceVersion  string            `json:"source_version"`
	RequestID      string            `json:"request_id"`
	URL            string            `json:"url"`
	FetchedAt      string            `json:"fetched_at"`
	HTTPStatus     int               `json:"http_status"`
	ContentType    string            `json:"content_type"`
	LatencyMS      int64             `json:"latency_ms"`
	Recipe         string            `json:"recipe"`
	Settings       map[string]string `json:"settings"`
	RequestedRoute RequestedRoute    `json:"requested_route"`
	RouteVerified  bool              `json:"route_verified"`
	Outcome        string            `json:"outcome"`
	Attempts       []RouteAttempt    `json:"attempts"`
	BodyKind       string            `json:"body_kind"`
}

Metadata is the project-neutral, service-validated capture envelope.

type RequestedRoute

type RequestedRoute struct {
	PoolID     string `json:"pool_id"`
	ProviderID string `json:"provider_id"`
	ProfileID  string `json:"profile_id"`
	Class      string `json:"class"`
}

type RouteAttempt

type RouteAttempt struct {
	ProviderID string `json:"provider_id"`
	AccountID  string `json:"account_id"`
	PoolID     string `json:"pool_id"`
	Class      string `json:"class"`
	Outcome    string `json:"outcome"`
}

type Storage

type Storage struct {
	Observations        int64 `json:"observations"`
	UniqueObjects       int64 `json:"unique_objects"`
	LogicalBodyBytes    int64 `json:"logical_body_bytes"`
	ReferencedGzipBytes int64 `json:"referenced_gzip_bytes"`
	UniqueGzipBytes     int64 `json:"unique_gzip_bytes"`
}

type TextDiff

type TextDiff struct {
	Equal        bool   `json:"equal"`
	Truncated    bool   `json:"truncated"`
	LeftExcerpt  string `json:"left_excerpt"`
	RightExcerpt string `json:"right_excerpt"`
}

Jump to

Keyboard shortcuts

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