Documentation
¶
Overview ¶
Package gcs provides a Google Cloud Storage client wrapper (cloud.google.com/go/storage) configured from config package.
Role in architecture:
- Infrastructure adapter: connects to GCS, exposes client and bucket; used by application code for object read/write.
Responsibilities:
- Setup: create storage client from config (credentials file or ADC); verify bucket access if BucketName set.
- GetClient, GetBucket, GetBucketName: access the client and default bucket.
- ReadObject, ReadObjectAsReader, WriteObject, DeleteObject, ObjectExists, ListObjects: map to GCS API calls with context.
- Close: close the client.
Constraints:
- SDK: cloud.google.com/go/storage. Single client and bucket per process; no provider switching.
- No business logic; only mapping to GCS operations.
- Credentials: config.GCS.CredentialsFile or Application Default Credentials.
This package must NOT:
- Contain use-case logic; only GCS operations.
Index ¶
- func Close() error
- func DeleteObject(objectName string) error
- func GetBucket() *storage.BucketHandle
- func GetBucketName() string
- func GetClient() *storage.Client
- func ListObjects(prefix string) ([]string, error)
- func ObjectExists(objectName string) (bool, error)
- func ReadObject(objectName string) ([]byte, error)
- func ReadObjectAsReader(objectName string) (io.ReadCloser, error)
- func Setup() error
- func WriteObject(objectName string, data []byte, contentType string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteObject ¶
DeleteObject deletes an object from GCS bucket
func GetBucket ¶
func GetBucket() *storage.BucketHandle
GetBucket returns the default bucket handle. Panics if bucket name is not configured.
func GetBucketName ¶
func GetBucketName() string
GetBucketName returns the configured bucket name (may be empty if not set).
func GetClient ¶
GetClient returns the storage client. Panics if Setup was not called or client is nil.
func ListObjects ¶
ListObjects lists objects in the bucket with the given prefix
func ObjectExists ¶
ObjectExists checks if an object exists in the bucket
func ReadObject ¶
ReadObject reads an object from GCS bucket
func ReadObjectAsReader ¶
func ReadObjectAsReader(objectName string) (io.ReadCloser, error)
ReadObjectAsReader returns a reader for an object from GCS bucket
Types ¶
This section is empty.