gcsstore

package module
v0.0.0-...-99d83a6 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 19 Imported by: 1

README

gcsstore

GoDoc CI

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

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, bucketName string, opts Options) (blob.StoreCloser, error)

New creates a new Store using the specified GCS bucket.

func Opener

func Opener(ctx context.Context, addr string) (blob.StoreCloser, 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_len  : shard prefix length (int)

Types

type KV

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

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

func (KV) Delete

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

Delete implements a method of the blob.KV interface.

func (KV) Get

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

Get implements a method of the blob.KV interface.

func (KV) Len

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

Len implements a method of the blob.KV interface.

func (KV) List

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

List implements a method of the blob.KV interface.

func (KV) Put

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

Put implements a method of the blob.KV interface.

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 be split to 012/01234567.
	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 KV.

type Store

type Store struct {
	*monitor.M[dbState, KV]
}

func (Store) Close

func (s Store) Close(ctx context.Context) error

Close implements part of the blob.StoreCloser interface.

Jump to

Keyboard shortcuts

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