gcsstore

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gcsstore is the objectstore.ObjectStore on Google Cloud Storage, over the JSON API and the media download of one object. It cannot list. No connection kind wires it to a flag source yet.

Index

Constants

This section is empty.

Variables

View Source
var ErrCloudEmulatorEnv = fmt.Errorf(
	"%w: STORAGE_EMULATOR_HOST is set: unset it and use the endpoint setting",
	objectstore.ErrInvalidConfig,
)

ErrCloudEmulatorEnv is the cause of a refused configuration: the library reads STORAGE_EMULATOR_HOST and would send the requests to that host with no credentials and no check of its address.

View Source
var ErrCloudTokenURI = fmt.Errorf(
	"%w: the token_uri of the key file is not a Google token endpoint",
	objectstore.ErrInvalidConfig,
)

ErrCloudTokenURI is the cause of a refused key file: its token_uri is not a Google token endpoint, so the signed assertion would be sent to another host.

View Source
var ErrCloudUniverseEnv = fmt.Errorf(
	"%w: GOOGLE_CLOUD_UNIVERSE_DOMAIN is set: unset it and use the endpoint setting",
	objectstore.ErrInvalidConfig,
)

ErrCloudUniverseEnv is the cause of a refused configuration: with no endpoint the library builds the host of the requests from GOOGLE_CLOUD_UNIVERSE_DOMAIN (storage.<domain>), and the token goes to that host.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Bucket is the bucket of the objects.
	Bucket string
	// Prefix is put before every key, with a slash between: a key of the flag set file is read at <prefix>/<key>. Empty
	// means none.
	Prefix string
	// Endpoint overrides the JSON API address, for an emulator or a private endpoint (https://host/storage/v1/). With
	// no CredentialsJSON the requests carry no credentials at all.
	Endpoint string
	// CredentialsJSON is the key file of a service account. Empty means the ambient credentials of the environment
	// (application default credentials) when there is no Endpoint, and none with one.
	CredentialsJSON storekit.Secret
	// RequestTimeout bounds one Get from the request to the last byte of the body. Zero means
	// [storekit.DefaultCloudRequestTimeout].
	RequestTimeout time.Duration
}

Config is the setting of a Store.

type Store

type Store struct {
	objectstore.NoLifecycle
	// contains filtered or unexported fields
}

Store is an objectstore.ObjectStore on a Google Cloud Storage bucket. The ETag is the generation of the object, and a conditional read is an ifGenerationNotMatch precondition: an unchanged object costs one request with no body. A version is a generation too. It issues the media download of the object and nothing else: no listing and no metadata request.

The client is built with the retries of the library turned off: the reader owns the retries and their budget, so a throttled request is not repeated inside the call. The library would still resume a body that broke with a second request that carries a Range header, or a second one for the same call (a body that broke before its first byte is reopened from offset zero with no header): the transport refuses it, and the read fails as retryable. A redirect to another host is refused (a token is added to every request), and a cleartext endpoint is dialled over loopback only. An object stored with Content-Encoding gzip is sent compressed and decoded on the way (the answer says nothing of its length), so the bytes the reader sees are the ones that were uploaded before they were compressed.

func New

func New(ctx context.Context, cfg *Config) (*Store, error)

New checks the setting and returns the store. ctx is used for the lookup of ambient credentials only; it does not bound the life of the store.

func (*Store) Close

func (s *Store) Close() error

Close releases the client and closes the idle connections of its transport.

func (*Store) Format

func (s *Store) Format(f fmt.State, _ rune)

Format implements fmt.Formatter: every verb prints the bucket and nothing of the setting.

func (*Store) Get

Get implements objectstore.ObjectStore. See Store for the rules.

Jump to

Keyboard shortcuts

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