Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- type MetricCollector
- type MultiPartStore
- func (m *MultiPartStore) AbortMultipartUpload(ctx context.Context, bucket string, key string, uploadID string) error
- func (m *MultiPartStore) CompleteMultipartUpload(ctx context.Context, bucket string, key string, uploadID string, ...) (string, error)
- func (m *MultiPartStore) InitMultipartUpload(ctx context.Context, bucket string, key string, uploadID string) error
- func (m *MultiPartStore) ListParts(ctx context.Context, bucket string, key string, uploadID string) (*UploadMeta, error)
- func (m *MultiPartStore) UploadPart(ctx context.Context, bucket string, key string, uploadID string, part int, ...) (string, error)
- type NatsObjectClient
- func (c *NatsObjectClient) Close()
- func (c *NatsObjectClient) CreateBucket(ctx context.Context, bucketName string) (jetstream.ObjectStoreStatus, error)
- func (c *NatsObjectClient) DeleteBucket(ctx context.Context, bucket string) error
- func (c *NatsObjectClient) DeleteObject(ctx context.Context, bucket string, key string) error
- func (c *NatsObjectClient) DeleteObjectTags(ctx context.Context, bucket string, key string) error
- func (c *NatsObjectClient) GetObject(ctx context.Context, bucket string, key string) (*jetstream.ObjectInfo, []byte, error)
- func (c *NatsObjectClient) GetObjectInfo(ctx context.Context, bucket string, key string) (*jetstream.ObjectInfo, error)
- func (c *NatsObjectClient) GetObjectRetention(ctx context.Context, bucket string, key string) (mode string, retainUntilDate string, err error)
- func (c *NatsObjectClient) IsConnected() bool
- func (c *NatsObjectClient) ListBuckets(ctx context.Context) (<-chan jetstream.ObjectStoreStatus, error)
- func (c *NatsObjectClient) ListObjects(ctx context.Context, bucket string) ([]*jetstream.ObjectInfo, error)
- func (c *NatsObjectClient) PutObjectRetention(ctx context.Context, bucket string, key string, mode string, ...) error
- func (c *NatsObjectClient) PutObjectStream(ctx context.Context, bucket string, key string, contentType string, ...) (*jetstream.ObjectInfo, error)
- func (c *NatsObjectClient) PutObjectTags(ctx context.Context, bucket string, key string, tagMetadata map[string]string) error
- func (c *NatsObjectClient) Stats() nats.Statistics
- type NatsObjectClientOptions
- type PartMeta
- type UploadMeta
Constants ¶
const ( MetaStoreName = "mp_meta" PartMetaStoreName = "mp_part_meta" TempStoreName = "mp_temp" )
Variables ¶
var ErrBucketAlreadyExists = errors.New("bucket already exists")
var ErrBucketNotFound = errors.New("bucket not found")
var ErrMissingPart = errors.New("missing part")
var ErrObjectNotFound = errors.New("object not found")
var ErrUploadCompleted = errors.New("completed multipart upload")
var ErrUploadNotFound = errors.New("multipart upload not found")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a NATS connection and metadata used by gateway components.
func NewClient ¶
NewClient creates a new Client with a generated ID and the provided kind used in connection names and logs.
type MetricCollector ¶ added in v0.3.1
type MetricCollector struct {
// contains filtered or unexported fields
}
func NewMetricCollector ¶ added in v0.3.1
func NewMetricCollector(logger log.Logger, client *NatsObjectClient) *MetricCollector
func (MetricCollector) Collect ¶ added in v0.3.1
func (c MetricCollector) Collect(ch chan<- prometheus.Metric)
Collect implements the prometheus.Collector interface.
func (MetricCollector) Describe ¶ added in v0.3.1
func (c MetricCollector) Describe(ch chan<- *prometheus.Desc)
Describe implements the prometheus.Collector interface.
type MultiPartStore ¶ added in v0.3.1
type MultiPartStore struct {
// contains filtered or unexported fields
}
MultiPartStore groups storage backends used for multipart uploads. metaStore tracks session metadata in a Key-Value bucket, while tempPartStore holds uploaded parts in a temporary Object Store.
func NewMultiPartStore ¶ added in v0.3.2
func NewMultiPartStore(logger log.Logger, c *Client) (*MultiPartStore, error)
func (*MultiPartStore) AbortMultipartUpload ¶ added in v0.3.2
func (m *MultiPartStore) AbortMultipartUpload(ctx context.Context, bucket string, key string, uploadID string) error
AbortMultipartUpload aborts an in‑progress multipart upload, deleting any uploaded parts and removing the session metadata.
func (*MultiPartStore) CompleteMultipartUpload ¶ added in v0.3.2
func (m *MultiPartStore) CompleteMultipartUpload(ctx context.Context, bucket string, key string, uploadID string, sortedPartNumbers []int) (string, error)
CompleteMultipartUpload concatenates the uploaded parts into the final object, computes and returns the multipart ETag, and cleans up temporary parts and metadata.
func (*MultiPartStore) InitMultipartUpload ¶ added in v0.3.2
func (m *MultiPartStore) InitMultipartUpload(ctx context.Context, bucket string, key string, uploadID string) error
InitMultipartUpload creates and persists a new multipart upload session for the given bucket/key and uploadID.
func (*MultiPartStore) ListParts ¶ added in v0.3.2
func (m *MultiPartStore) ListParts(ctx context.Context, bucket string, key string, uploadID string) (*UploadMeta, error)
ListParts returns the multipart upload metadata for the given bucket/key/uploadID, including uploaded parts with sizes and ETags.
func (*MultiPartStore) UploadPart ¶ added in v0.3.2
func (m *MultiPartStore) UploadPart(ctx context.Context, bucket string, key string, uploadID string, part int, dataReader io.ReadCloser) (string, error)
UploadPart streams a part into temporary storage and records its ETag/size under the multipart session. Returns the hex ETag (without quotes).
type NatsObjectClient ¶
type NatsObjectClient struct {
// contains filtered or unexported fields
}
NatsObjectClient provides convenience helpers for common NATS JetStream Object Store operations, built on top of the base Client connection.
func NewNatsObjectClient ¶ added in v0.3.1
func NewNatsObjectClient(logger log.Logger, natsClient *Client, opts NatsObjectClientOptions) (*NatsObjectClient, error)
func (*NatsObjectClient) Close ¶ added in v0.4.1
func (c *NatsObjectClient) Close()
Close closes the underlying NATS connection.
func (*NatsObjectClient) CreateBucket ¶
func (c *NatsObjectClient) CreateBucket(ctx context.Context, bucketName string) (jetstream.ObjectStoreStatus, error)
CreateBucket creates a JetStream Object Store bucket.
func (*NatsObjectClient) DeleteBucket ¶
func (c *NatsObjectClient) DeleteBucket(ctx context.Context, bucket string) error
DeleteBucket deletes a bucket identified by its name.
func (*NatsObjectClient) DeleteObject ¶
DeleteObject removes an object identified by bucket and key.
func (*NatsObjectClient) DeleteObjectTags ¶ added in v0.4.0
DeleteObjectTags removes all tags from an object.
func (*NatsObjectClient) GetObject ¶
func (c *NatsObjectClient) GetObject(ctx context.Context, bucket string, key string) (*jetstream.ObjectInfo, []byte, error)
GetObject retrieves an object's metadata and bytes.
func (*NatsObjectClient) GetObjectInfo ¶
func (c *NatsObjectClient) GetObjectInfo(ctx context.Context, bucket string, key string) (*jetstream.ObjectInfo, error)
GetObjectInfo fetches metadata for an object.
func (*NatsObjectClient) GetObjectRetention ¶ added in v0.3.3
func (c *NatsObjectClient) GetObjectRetention(ctx context.Context, bucket string, key string) (mode string, retainUntilDate string, err error)
GetObjectRetention retrieves retention metadata for an object
func (*NatsObjectClient) IsConnected ¶ added in v0.3.1
func (c *NatsObjectClient) IsConnected() bool
IsConnected checks if NATS is connected
func (*NatsObjectClient) ListBuckets ¶
func (c *NatsObjectClient) ListBuckets(ctx context.Context) (<-chan jetstream.ObjectStoreStatus, error)
ListBuckets returns a channel of object store statuses for all buckets.
func (*NatsObjectClient) ListObjects ¶
func (c *NatsObjectClient) ListObjects(ctx context.Context, bucket string) ([]*jetstream.ObjectInfo, error)
ListObjects lists all objects in the given bucket.
func (*NatsObjectClient) PutObjectRetention ¶ added in v0.3.3
func (c *NatsObjectClient) PutObjectRetention(ctx context.Context, bucket string, key string, mode string, retainUntilDate string) error
PutObjectRetention sets retention metadata for an existing object
func (*NatsObjectClient) PutObjectStream ¶ added in v0.3.10
func (c *NatsObjectClient) PutObjectStream(ctx context.Context, bucket string, key string, contentType string, metadata map[string]string, reader io.Reader) (*jetstream.ObjectInfo, error)
PutObjectStream writes an object using a streaming reader.
func (*NatsObjectClient) PutObjectTags ¶ added in v0.4.0
func (c *NatsObjectClient) PutObjectTags(ctx context.Context, bucket string, key string, tagMetadata map[string]string) error
PutObjectTags sets or replaces tags on an existing object. Tags are stored in metadata with "x-amz-tag-" prefix.
func (*NatsObjectClient) Stats ¶ added in v0.3.1
func (c *NatsObjectClient) Stats() nats.Statistics
Stats returns NATS statistics
type NatsObjectClientOptions ¶ added in v0.3.9
type NatsObjectClientOptions struct {
Replicas int
}
type PartMeta ¶ added in v0.3.1
type PartMeta struct {
Number int `json:"number"`
ETag string `json:"etag"`
Size uint64 `json:"size"`
StoredAt int64 `json:"stored_at_unix"`
}
PartMeta describes a single part in a multipart upload. It records the part number, ETag (checksum), size in bytes, and the time the part was stored (Unix seconds).
type UploadMeta ¶ added in v0.3.1
type UploadMeta struct {
UploadID string `json:"upload_id"`
Bucket string `json:"bucket"`
Key string `json:"key"`
Initiated time.Time `json:"initiated"`
Owner string `json:"owner,omitempty"` // optional, auth principal
MinPartSz int64 `json:"min_part_size"` // default 5MiB
MaxParts int `json:"max_parts"` // default 10000
Parts map[int]PartMeta `json:"-"` // Not persisted, populated on-demand
}
UploadMeta captures the server-side state of a multipart upload. It includes identifiers (UploadID, Bucket, Key), initiation time (UTC), optional owner, and constraints (minimum part size and max parts). The JSON value is persisted in a Key-Value store under a session-specific key. Individual part metadata is stored in separate KV entries to avoid write conflicts. The Parts field is populated on-demand when calling ListParts or CompleteMultipartUpload.