s3

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2025 License: Apache-2.0 Imports: 28 Imported by: 3

Documentation

Index

Constants

View Source
const DefaultRegion = "us-east-1"

DefaultRegion is the region used if one is not specified.

View Source
const MaxKeys = 1000

MaxKeys is the number of keys S3 can operate on per batch.

View Source
const MetadataKeyTimestamp = "litestream-timestamp"

MetadataKeyTimestamp is the metadata key for storing LTX file timestamps in S3.

View Source
const ReplicaClientType = "s3"

ReplicaClientType is the client type for this package.

Variables

This section is empty.

Functions

func ParseHost added in v0.3.3

func ParseHost(host string) (bucket, region, endpoint string, forcePathStyle bool)

ParseHost parses the host/endpoint for an S3-like storage system. Endpoints: https://docs.aws.amazon.com/general/latest/gr/s3.html

func ParseURL added in v0.5.0

func ParseURL(s, endpoint string) (bucket, region, key string, err error)

ParseURL parses an S3 URL into its host and path parts. If endpoint is set, it can override the host.

Types

type ReplicaClient added in v0.3.5

type ReplicaClient struct {

	// AWS authentication keys.
	AccessKeyID     string
	SecretAccessKey string

	// S3 bucket information
	Region         string
	Bucket         string
	Path           string
	Endpoint       string
	ForcePathStyle bool
	SkipVerify     bool

	// Upload configuration
	PartSize    int64 // Part size for multipart uploads (default: 5MB)
	Concurrency int   // Number of concurrent parts to upload (default: 5)
	// contains filtered or unexported fields
}

ReplicaClient is a client for writing LTX files to S3.

func NewReplicaClient added in v0.3.5

func NewReplicaClient() *ReplicaClient

NewReplicaClient returns a new instance of ReplicaClient.

func (*ReplicaClient) DeleteAll added in v0.3.5

func (c *ReplicaClient) DeleteAll(ctx context.Context) error

DeleteAll deletes all files.

func (*ReplicaClient) DeleteLTXFiles added in v0.5.0

func (c *ReplicaClient) DeleteLTXFiles(ctx context.Context, a []*ltx.FileInfo) error

DeleteLTXFiles deletes one or more LTX files.

func (*ReplicaClient) Init added in v0.3.5

func (c *ReplicaClient) Init(ctx context.Context) (err error)

Init initializes the connection to S3. No-op if already initialized.

func (*ReplicaClient) LTXFiles added in v0.5.0

func (c *ReplicaClient) LTXFiles(ctx context.Context, level int, seek ltx.TXID, useMetadata bool) (ltx.FileIterator, error)

LTXFiles returns an iterator over all LTX files on the replica for the given level. When useMetadata is true, fetches accurate timestamps from S3 metadata via HeadObject. When false, uses fast LastModified timestamps from LIST operation.

func (*ReplicaClient) OpenLTXFile added in v0.5.0

func (c *ReplicaClient) OpenLTXFile(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, offset, size int64) (io.ReadCloser, error)

OpenLTXFile returns a reader for an LTX file Returns os.ErrNotExist if no matching index/offset is found.

func (*ReplicaClient) Type added in v0.3.5

func (c *ReplicaClient) Type() string

Type returns "s3" as the client type.

func (*ReplicaClient) WriteLTXFile added in v0.5.0

func (c *ReplicaClient) WriteLTXFile(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, r io.Reader) (*ltx.FileInfo, error)

WriteLTXFile writes an LTX file to the replica. Extracts timestamp from LTX header and stores it in S3 metadata to preserve original creation time.

Jump to

Keyboard shortcuts

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