spannerauth

package
v1.76.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Error is a class of spannerauth errors.
	Error = errs.Class("spannerauth")
)

Functions

func EmulatorOpts

func EmulatorOpts(addr string) []option.ClientOption

EmulatorOpts returns ClientOptions for Cloud Spanner Emulator.

Types

type CloudDatabase

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

CloudDatabase represents a remote Cloud Spanner database that implements the Storage interface.

func Open

func Open(ctx context.Context, logger *zap.Logger, config Config) (*CloudDatabase, error)

Open returns initialized CloudDatabase connected to Cloud Spanner. If address is specified in config, it configures options for Cloud Spanner Emulator.

func (*CloudDatabase) Close

func (d *CloudDatabase) Close() error

Close closes the remote Cloud Spanner database.

func (*CloudDatabase) Delete added in v1.67.0

func (d *CloudDatabase) Delete(ctx context.Context, keyHash authdb.KeyHash) (err error)

Delete deletes the record.

func (*CloudDatabase) Get

func (d *CloudDatabase) Get(ctx context.Context, keyHash authdb.KeyHash) (_ *authdb.Record, err error)

Get retrieves the record from the remote Cloud Spanner database. It returns (nil, nil) if the key does not exist. If the record is invalid, the error contains why.

func (*CloudDatabase) GetFullRecord added in v1.69.0

func (d *CloudDatabase) GetFullRecord(ctx context.Context, keyHash authdb.KeyHash) (_ *authdb.FullRecord, err error)

GetFullRecord retrieves the record from the remote Cloud Spanner database. It returns (nil, nil) if the key does not exist.

func (*CloudDatabase) HealthCheck

func (d *CloudDatabase) HealthCheck(ctx context.Context) error

HealthCheck ensures there's connectivity to the remote Cloud Spanner database and returns an error otherwise.

func (*CloudDatabase) Invalidate added in v1.67.0

func (d *CloudDatabase) Invalidate(ctx context.Context, keyHash authdb.KeyHash, reason string) (err error)

Invalidate invalidates the record.

func (*CloudDatabase) Put

func (d *CloudDatabase) Put(ctx context.Context, keyHash authdb.KeyHash, record *authdb.Record) (err error)

Put stores the record in the remote Cloud Spanner database. It is an error if the key already exists.

func (*CloudDatabase) PutWithCreatedAt

func (d *CloudDatabase) PutWithCreatedAt(ctx context.Context, keyHash authdb.KeyHash, record *authdb.Record, createdAt time.Time) (err error)

PutWithCreatedAt is a temporary addition to ensure we migrate the created date when used with spannerauthmigration, because authdb.Record has no way of setting this directly. This should be removed once the migration has completed.

func (*CloudDatabase) Run

func (d *CloudDatabase) Run(ctx context.Context) error

Run is a no-op.

func (*CloudDatabase) Unpublish added in v1.67.0

func (d *CloudDatabase) Unpublish(ctx context.Context, keyHash authdb.KeyHash) (err error)

Unpublish unpublishes the record.

type Config

type Config struct {
	DatabaseName        string `user:"true" help:"name of Cloud Spanner database in the form projects/PROJECT_ID/instances/INSTANCE_ID/databases/DATABASE_ID"`
	CredentialsFilename string `user:"true" help:"credentials file with access to Cloud Spanner database"`

	// Address is used for Cloud Spanner Emulator in tests.
	Address string `internal:"true"`
}

Config is config to configure the Cloud Spanner database.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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