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
- type BodyResult
- type Capture
- type CaptureWrite
- type CaptureWriteResult
- type Client
- func (c *Client) Compare(ctx context.Context, left, right string) (Comparison, error)
- func (c *Client) Create(ctx context.Context, m Metadata, body []byte) (CreateResult, error)
- func (c *Client) CreateBatch(ctx context.Context, pages []CaptureWrite) ([]CaptureWriteResult, error)
- func (c *Client) CreateDerivation(ctx context.Context, captureID string, m DerivationMetadata, ...) (DerivationResult, error)
- func (c *Client) CreateDerivationBatch(ctx context.Context, captureID string, items []DerivationWrite) ([]DerivationResult, error)
- func (c *Client) CreateMultiCaptureDerivations(ctx context.Context, groups []DerivationGroup, raw bool) ([]DerivationGroupResult, error)
- func (c *Client) CreateRawDerivationBatch(ctx context.Context, captureID string, items []DerivationWrite) ([]DerivationResult, error)
- func (c *Client) CreateWithDigest(ctx context.Context, m Metadata, body []byte, digest string) (CreateResult, error)
- func (c *Client) DerivationBody(ctx context.Context, d Derivation) (json.RawMessage, error)
- func (c *Client) Download(ctx context.Context, id string) ([]byte, error)
- func (c *Client) DownloadCapture(ctx context.Context, capture Capture) ([]byte, error)
- func (c *Client) Get(ctx context.Context, id string) (Capture, error)
- func (c *Client) GetDerivation(ctx context.Context, id string) (Derivation, error)
- func (c *Client) List(ctx context.Context, o ListOptions) (ListResult, error)
- func (c *Client) ListDerivations(ctx context.Context, o DerivationListOptions) (DerivationList, error)
- func (c *Client) OpenBody(ctx context.Context, id string) (BodyResult, error)
- func (c *Client) Storage(ctx context.Context) (Storage, error)
- type Comparison
- type Config
- type CreateResult
- type Derivation
- type DerivationBatch
- type DerivationGroup
- type DerivationGroupResult
- type DerivationList
- type DerivationListOptions
- type DerivationMetadata
- type DerivationResult
- type DerivationWrite
- type ListOptions
- type ListResult
- type Metadata
- type RequestedRoute
- type RouteAttempt
- type Storage
- type TextDiff
Constants ¶
const ( MaxBodyBytes = 8 << 20 MaxMetadataBytes = 16 << 10 DefaultTimeout = 5 * time.Second )
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 CaptureWrite ¶ added in v0.140.4
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 (*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) DownloadCapture ¶ added in v0.140.4
DownloadCapture verifies the downloaded body against its previously read index metadata in the same pass as verifying the download receipt.
func (*Client) GetDerivation ¶ added in v0.134.6
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)
type Comparison ¶
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 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 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 ListResult ¶
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.