s3

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package s3 wraps an S3-compatible object store client (AWS S3, Cloudflare R2, MinIO, etc.) with the minimal surface needed by xatu output sinks: connect, PutObject. Higher-level sinks layer their own event-shape semantics on top.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps an S3-compatible object store client.

func New

New builds a Client. The connection is established lazily on first use; callers should issue a HEAD against the bucket via HeadBucket if they want startup-time validation.

func (*Client) Bucket

func (c *Client) Bucket() string

Bucket returns the bucket name this client targets.

func (*Client) HeadBucket

func (c *Client) HeadBucket(ctx context.Context) error

HeadBucket checks the configured bucket is reachable and the credentials work. Suitable to call from a sink's Start.

func (*Client) PutObject

func (c *Client) PutObject(ctx context.Context, key string, body []byte, opts PutOptions) error

PutObject uploads body as a single object at the given key. The body is uploaded verbatim — no compression, no encoding transforms.

type Config

type Config struct {
	// Endpoint is the S3 endpoint host. For Cloudflare R2 use the
	// account-scoped endpoint (e.g. "<account>.r2.cloudflarestorage.com").
	// For AWS use the regional endpoint (e.g. "s3.us-east-1.amazonaws.com").
	// Must NOT include a scheme — set Insecure to toggle HTTPS/HTTP.
	Endpoint string `yaml:"endpoint"`

	// Bucket is the destination bucket name. Must already exist.
	Bucket string `yaml:"bucket"`

	// Region is the bucket region. Required by AWS, ignored by R2/MinIO
	// but harmless. Defaults to "auto" which works for R2.
	Region string `yaml:"region" default:"auto"`

	// AccessKeyID and SecretAccessKey authenticate the client. Required.
	AccessKeyID     string `yaml:"accessKeyId"`
	SecretAccessKey string `yaml:"secretAccessKey"`

	// Insecure disables HTTPS (plain HTTP). Defaults to false — i.e. SSL
	// is used. Modeled as opt-in plain-HTTP rather than opt-in SSL because
	// `bool` zero-value defaulting traps the opposite shape: an explicit
	// `useSsl: false` would be indistinguishable from "unset" and get
	// overridden back to true by the defaults loader.
	Insecure bool `yaml:"insecure"`
}

Config configures an S3-compatible client. It is YAML-inlineable so higher-level sinks can embed it directly under their own `config:` block.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks for the minimum required fields.

type PutOptions

type PutOptions struct {
	// ContentType is the MIME type (e.g. "text/plain").
	ContentType string

	// ContentEncoding is the Content-Encoding header (e.g. "gzip" when
	// Body is already gzip-compressed).
	ContentEncoding string
}

PutOptions describes per-object metadata applied at upload time. Body bytes are uploaded verbatim — callers that want compression or encoding must do it before calling PutObject and set the matching header fields here.

Jump to

Keyboard shortcuts

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