spanner

package
v0.0.0-...-9982bc2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgsToParams

func ArgsToParams(args []interface{}) map[string]interface{}

func Delete

func Delete[K Keys](db BufferWriter, t tables.Table, keys ...K) error

func DeleteByBuilder

func DeleteByBuilder(ctx context.Context, db Updater, b squirrel.DeleteBuilder) (int64, error)

func ExistsKey

func ExistsKey[K Key](ctx context.Context, db RowReader, t tables.Table, k K) (bool, error)

func GetByKey

func GetByKey[M any, K Key](ctx context.Context, db RowReader, t tables.Table, k K) (m M, err error)

func GetByKeys

func GetByKeys[M any, K Keys](ctx context.Context, db Reader, t tables.Table, ids ...K) ([]M, error)

func GetPtrResults

func GetPtrResults[M any](iter *spanner.RowIterator) (out []*M, err error)

GetPtrResults returns the results from the iterator. Calls Stop after the iterator is finished.

func GetResult

func GetResult[M any](iter *spanner.RowIterator) (out M, err error)

GetResult returns the result from the iterator. Calls Stop after the iterator is finished.

func GetResultByBuilder

func GetResultByBuilder[M any](ctx context.Context, db Queryer, b squirrel.SelectBuilder) (m M, err error)

func GetResults

func GetResults[M any](iter *spanner.RowIterator) (out []M, err error)

GetResults returns the results from the iterator. Calls Stop after the iterator is finished.

func GetResultsByBuilder

func GetResultsByBuilder[M any](ctx context.Context, db Queryer, b squirrel.SelectBuilder) ([]M, error)

func GetStreak

func GetStreak(ctx context.Context, db Queryer, userID string, streakType int64) ([]repo.Streak, error)

func GetStreaksHistory

func GetStreaksHistory(
	ctx context.Context,
	db Queryer,
	userID string,
	streakType int64,
	c cursor.Cursor,
) ([]repo.Streak, error)

func InsertByBuilder

func InsertByBuilder(ctx context.Context, db Updater, b squirrel.InsertBuilder) (int64, error)

func NewSpannerClient

func NewSpannerClient(ctx context.Context, dsn, adcCredPath string) (*spanner.Client, error)

func UpdateByBuilder

func UpdateByBuilder(ctx context.Context, db Updater, b squirrel.UpdateBuilder) (int64, error)

func UpsertStreak

func UpsertStreak(_ context.Context, db BufferWriter, in repo.Streak) error

Types

type BufferWriter

type BufferWriter interface {
	BufferWrite([]*spanner.Mutation) error
}

type DBWriter

type DBWriter interface {
	Updater
	BufferWriter
}

type IndexReader

type IndexReader interface {
	ReadUsingIndex(ctx context.Context, table, index string, keys spanner.KeySet, columns []string) *spanner.RowIterator
}

type Key

type Key interface{ string | spanner.Key }

type Keys

type Keys interface{ Key | spanner.KeyRange }

type Queryer

type Queryer interface {
	Query(context.Context, spanner.Statement) *spanner.RowIterator
}

type ReadWriter

type ReadWriter interface {
	Reader
	BufferWriter
}

type Reader

type Reader interface {
	Read(ctx context.Context, table string, k spanner.KeySet, cols []string) *spanner.RowIterator
}

type Repo

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

func NewRepoWithClient

func NewRepoWithClient(cli *spanner.Client) Repo

func (Repo) ReadOnlyTx

func (r Repo) ReadOnlyTx(ctx context.Context, f func(context.Context, repo.ReadActions) error) error

func (Repo) ReadWriteTx

func (r Repo) ReadWriteTx(
	ctx context.Context,
	f func(context.Context, repo.ReadWriteActions) error,
) (time.Time, error)

func (Repo) SingleRead

func (r Repo) SingleRead() repo.ReadActions

func (Repo) SingleWrite

func (r Repo) SingleWrite() repo.WriteActions

type RowReader

type RowReader interface {
	ReadRow(ctx context.Context, table string, k spanner.Key, cols []string) (*spanner.Row, error)
}

type Updater

type Updater interface {
	Update(context.Context, spanner.Statement) (int64, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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