client

package
v0.0.0-...-30aa497 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Copyright 2025 Accelerated Cloud Storage Corporation. All Rights Reserved. Package client provides a Go client for interacting with the Accelerated Cloud Storage service.

Copyright 2025 Accelerated Cloud Storage Corporation. All Rights Reserved. Package client provides a Go client for interacting with the Accelerated Cloud Storage service.

Copyright 2025 Accelerated Cloud Storage Corporation. All Rights Reserved. Package client provides a Go client for interacting with the Accelerated Cloud Storage service.

Copyright 2025 Accelerated Cloud Storage Corporation. All Rights Reserved. Package client provides a Go client for interacting with the Accelerated Cloud Storage service.

Copyright 2025 Accelerated Cloud Storage Corporation. All Rights Reserved. Package client provides a Go client for interacting with the Accelerated Cloud Storage service.

Index

Constants

This section is empty.

Variables

View Source
var DefaultRetryConfig = RetryConfig{
	MaxAttempts:      5,
	InitialBackoff:   100 * time.Millisecond,
	MaxBackoff:       5 * time.Second,
	BackoffMultipler: 2.0,
}

DefaultRetryConfig provides reasonable default values for retry behavior.

Functions

This section is empty.

Types

type ACSClient

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

ACSClient wraps the gRPC connection and client for ObjectStorageCache. It provides high-level operations for interacting with the ACS service.

func NewClient

func NewClient(session *Session) (*ACSClient, error)

NewClient initializes a new gRPC client with authentication. It establishes a secure connection to the ACS service, loads credentials, and performs initial authentication.

func (*ACSClient) Close

func (client *ACSClient) Close() error

Close terminates the client connection. It should be called when the client is no longer needed to free resources.

func (*ACSClient) CopyObject

func (client *ACSClient) CopyObject(ctx context.Context, bucket, copySource, key string) error

CopyObject copies an object from a source bucket/key to a destination bucket/key. It returns an error if the copy operation fails.

func (*ACSClient) CreateBucket

func (client *ACSClient) CreateBucket(ctx context.Context, bucket string) error

CreateBucket sends a request to create a new bucket. It requires a bucket name and region specification and returns an error if bucket creation fails.

func (*ACSClient) DeleteBucket

func (client *ACSClient) DeleteBucket(ctx context.Context, bucket string) error

DeleteBucket requests deletion of the specified bucket. It returns an error if bucket deletion fails or if the bucket doesn't exist.

func (*ACSClient) DeleteObject

func (client *ACSClient) DeleteObject(ctx context.Context, bucket, key string) error

DeleteObject removes a single object from a bucket. It returns an error if deletion fails.

func (*ACSClient) DeleteObjects

func (client *ACSClient) DeleteObjects(ctx context.Context, bucket string, keys []string) error

DeleteObjects requests bulk deletion of objects in a bucket. It returns an error if any object deletion fails.

func (*ACSClient) GetObject

func (client *ACSClient) GetObject(ctx context.Context, bucket, key string, options ...GetObjectOption) ([]byte, error)

GetObject downloads the specified object from the server. If rangeSpec is provided in the format "bytes=start-end" (e.g., "bytes=0-9" for first 10 bytes), only the specified range of the object will be downloaded. It returns the object's data and an error if the download fails.

func (*ACSClient) HeadBucket

func (client *ACSClient) HeadBucket(ctx context.Context, bucket string) (*HeadBucketOutput, error)

HeadBucket retrieves metadata for a specific bucket. It returns the bucket's metadata and an error if the operation fails.

func (*ACSClient) HeadObject

func (client *ACSClient) HeadObject(ctx context.Context, bucket, key string) (*HeadObjectOutput, error)

HeadObject retrieves metadata for a specific object. It returns the object's metadata and an error if the operation fails.

func (*ACSClient) ListBuckets

func (client *ACSClient) ListBuckets(ctx context.Context) ([]*pb.Bucket, error)

ListBuckets retrieves all buckets from the server. It returns a list of bucket objects and an error if the operation fails.

func (*ACSClient) ListObjects

func (client *ACSClient) ListObjects(ctx context.Context, bucket string, opts *ListObjectsOptions) ([]string, error)

ListObjects retrieves object keys from the server based on given options. It returns a list of object keys and an error if the operation fails.

func (*ACSClient) PutObject

func (client *ACSClient) PutObject(ctx context.Context, bucket, key string, data []byte) error

PutObject uploads data to the specified bucket and key. It automatically compresses large objects when beneficial and returns an error if the upload fails.

func (*ACSClient) RotateKey

func (client *ACSClient) RotateKey(ctx context.Context, force bool) error

RotateKey checks whether key rotation is needed and performs it if necessary. The force parameter may be used to force rotation regardless of timing. It returns an error if the rotation fails.

func (*ACSClient) ShareBucket

func (client *ACSClient) ShareBucket(ctx context.Context, bucket string) error

ShareBucket informs the service about a bucket that has been shared with it. It returns an error if the sharing operation fails or if permissions are insufficient.

type GetObjectOption

type GetObjectOption func(*GetObjectOptions)

GetObjectOption is a function that configures GetObjectOptions

func WithRange

func WithRange(rangeSpec string) GetObjectOption

WithRange specifies a range for the GetObject operation The range should be in the format "bytes=start-end" (e.g., "bytes=0-9" for first 10 bytes)

type GetObjectOptions

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

GetObjectOptions holds the options for GetObject

type HeadBucketOutput

type HeadBucketOutput struct {
	// Region specifies the region where the bucket is located
	Region string
}

HeadBucketOutput represents the metadata returned by HeadBucket operation. It contains information about a bucket's configuration and status.

type HeadObjectOutput

type HeadObjectOutput struct {
	// ContentType specifies the MIME type of the object
	ContentType string
	// ContentEncoding specifies the encoding of the object content
	ContentEncoding string
	// ContentLanguage specifies the language the object content is in
	ContentLanguage string
	// ContentLength specifies the size of the object in bytes
	ContentLength int64
	// LastModified is the last modification timestamp
	LastModified time.Time
	// ETag is the entity tag for the object
	ETag string
	// UserMetadata contains user-defined metadata key-value pairs
	UserMetadata map[string]string
	// ServerSideEncryption specifies the type of server-side encryption used
	ServerSideEncryption string
	// VersionId is the version identifier for the object
	VersionId string
}

HeadObjectOutput represents the metadata returned by HeadObject operation. It contains detailed information about an object's properties and metadata.

type ListObjectsOptions

type ListObjectsOptions struct {
	// Prefix filters objects by prefix
	Prefix string
	// StartAfter returns objects lexicographically after this value
	StartAfter string
	// MaxKeys specifies the maximum number of keys to return
	MaxKeys int32
}

ListObjectsOptions holds optional parameters for object listing. These options allow for customizing the object listing operation.

type RetryConfig

type RetryConfig struct {
	// MaxAttempts is the maximum number of retry attempts.
	MaxAttempts int
	// InitialBackoff is the initial backoff duration.
	InitialBackoff time.Duration
	// MaxBackoff is the maximum backoff duration.
	MaxBackoff time.Duration
	// BackoffMultipler is the multiplier for exponential backoff.
	BackoffMultipler float64
}

RetryConfig defines the configuration for retry behavior. It is used by retry logic to configure attempt limits and backoff.

type Session

type Session struct {
	// Region specifies the AWS region to use for this session
	Region string
}

Session represents a client session configuration. It contains optional parameters that can be provided when creating a new client.

Jump to

Keyboard shortcuts

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