gcsstore

package module
v0.0.0-...-6b9f32f Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 15 Imported by: 1

README

gcsstore

GoDoc

Package gcsstore implements the blob.Store interface using Google Cloud Storage.

Documentation

Overview

Package gcsstore implements the blob.Store interface using a GCS bucket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Opener

func Opener(ctx context.Context, addr string) (blob.Store, error)

Opener constructs a Store from an address comprising a GCS bucket name, for use with the store package.

The format of addr is "[prefix@]bucket-name[?query]".

Query parameters:

shard_prefix  : shard prefix length (int)

Types

type Options

type Options struct {
	// The prefix to prepend to each key written by the store.
	// If unset, no prefix is prepended and keys are written at the top level.
	// See also ShardPrefixLen.
	Prefix string

	// The length of the key shard prefix. If positive, the key is partitioned
	// into a prefix of this length and a suffix comprising the rest of the key,
	// separated by a "/". For example, if ShardPrefixLen is 3, then the key
	// 01234567 will besplit to 012/34567.
	ShardPrefixLen int

	// If set, the bucket will be created in this project if it does not exist.
	Project string

	// If set, options to pass when creating a bucket.
	BucketAttrs *storage.BucketAttrs

	// If not nil, return JSON credentials.
	Credentials func(context.Context) ([]byte, error)

	// If true and credentials are not provided, connect without authentication.
	// If false, default application credentials will be used from the environment.
	Unauthenticated bool
}

Options control the construction of a *Store.

type Store

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

A Store implements the blob.Store interface using a GCS bucket.

func New

func New(ctx context.Context, bucketName string, opts Options) (*Store, error)

New creates a new storage client for the given bucket.

func (*Store) Close

func (s *Store) Close(_ context.Context) error

Close closes the client associated with s.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, key string) error

Delete implements a method of the blob.Store interface.

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) ([]byte, error)

Get implements a method of the blob.Store interface.

func (*Store) Len

func (s *Store) Len(ctx context.Context) (int64, error)

Len implements a method of the blob.Store interface.

func (*Store) List

func (s *Store) List(ctx context.Context, start string, f func(string) error) error

List implements a method of the blob.Store interface.

func (*Store) Put

func (s *Store) Put(ctx context.Context, opts blob.PutOptions) error

Put implements a method of the blob.Store interface.

Jump to

Keyboard shortcuts

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