oss

package
v0.5.3-beta1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRegion = "cn-hangzhou"

DefaultRegion is the region used if one is not specified.

View Source
const MaxKeys = 1000

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

View Source
const MetadataKeyTimestamp = "litestream-timestamp"

MetadataKeyTimestamp is the metadata key for storing LTX file timestamps in OSS. Note: OSS SDK automatically adds "x-oss-meta-" prefix when setting metadata.

View Source
const ReplicaClientType = "oss"

ReplicaClientType is the client type for this package.

Variables

This section is empty.

Functions

func ParseHost

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

ParseHost parses the host/endpoint for an OSS storage system. Supports formats like:

  • bucket.oss-cn-hangzhou.aliyuncs.com
  • bucket.oss-cn-hangzhou-internal.aliyuncs.com
  • bucket (just bucket name)

func ParseURL

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

ParseURL parses an OSS URL into its host and path parts.

Types

type ReplicaClient

type ReplicaClient struct {

	// Alibaba Cloud authentication keys.
	AccessKeyID     string
	AccessKeySecret string

	// OSS bucket information
	Region   string
	Bucket   string
	Path     string
	Endpoint string

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

ReplicaClient is a client for writing LTX files to Alibaba Cloud OSS.

func NewReplicaClient

func NewReplicaClient() *ReplicaClient

NewReplicaClient returns a new instance of ReplicaClient.

func (*ReplicaClient) DeleteAll

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

DeleteAll deletes all files.

func (*ReplicaClient) DeleteLTXFiles

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

DeleteLTXFiles deletes one or more LTX files.

func (*ReplicaClient) Init

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

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

func (*ReplicaClient) LTXFiles

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 OSS metadata via HeadObject. When false, uses fast LastModified timestamps from LIST operation.

func (*ReplicaClient) OpenLTXFile

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 file is found.

func (*ReplicaClient) Type

func (c *ReplicaClient) Type() string

Type returns "oss" as the client type.

func (*ReplicaClient) WriteLTXFile

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 OSS metadata to preserve original creation time. Uses multipart upload for large files via the uploader.

Jump to

Keyboard shortcuts

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