spanner

package
v0.0.0-...-e6f7b9e Latest Latest
Warning

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

Go to latest
Published: Jul 6, 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 Table, keys ...K) error

func DeleteByBuilder

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

func DeleteCircle

func DeleteCircle(_ context.Context, db BufferWriter, circle repo.CircleKey) error

func DeleteSearch

func DeleteSearch(_ context.Context, db BufferWriter, in repo.SearchKey) error

func ExistsKey

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

func ExistsUser

func ExistsUser(
	ctx context.Context,
	db RowReader,
	key repo.UserKey,
) (bool, error)

func GetByKey

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

func GetByKeys

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

func GetCircle

func GetCircle(ctx context.Context, db RowReader, key repo.CircleKey) (repo.Circle, error)

func GetPostClassificationTags

func GetPostClassificationTags(ctx context.Context, db Reader, postID string) ([]string, error)

func GetPosts

func GetPosts(ctx context.Context, db Reader, postIDs ...string) ([]repo.Post, 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 GetSearches

func GetSearches(
	ctx context.Context,
	db Queryer,
	kind int64,
	userID string,
	c cursor.Cursor,
) ([]repo.Search, error)

func GetUser

func GetUser(ctx context.Context, db RowReader, key repo.UserKey) (repo.User, error)

func GetUserUserEdge

func GetUserUserEdge(
	ctx context.Context,
	db RowReader,
	key repo.UserUserEdgeKey,
) (repo.UserUserEdge, error)

func InsertByBuilder

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

func InsertPosts

func InsertPosts(_ context.Context, db BufferWriter, posts ...repo.Post) error

func InsertUser

func InsertUser(
	_ context.Context,
	db BufferWriter,
	input repo.InsertUserInput,
) error

func InsertUserCircleEdge

func InsertUserCircleEdge(_ context.Context, db BufferWriter, userCircleEdge repo.UserCircleEdge) error

func NewSpannerClient

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

func PartialUpdateUser

func PartialUpdateUser(
	_ context.Context,
	db BufferWriter,
	input repo.PartialUpdateUserInput,
) error

func PartialUpdateUserCircleEdge

func PartialUpdateUserCircleEdge(
	_ context.Context,
	db BufferWriter,
	input repo.PartialUpdateUserCircleEdgeInput,
) error

func PartialUpdateUserUserEdge

func PartialUpdateUserUserEdge(
	_ context.Context,
	db BufferWriter,
	input repo.PartialUpdateUserUserEdgeInput,
) error

func RemovePost

func RemovePost(_ context.Context, db BufferWriter, postID string, deletedAt time.Time) error

func UpdateByBuilder

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

func UpsertCircle

func UpsertCircle(_ context.Context, db BufferWriter, circle repo.Circle) error

func UpsertPostClassificationTags

func UpsertPostClassificationTags(_ context.Context, db BufferWriter, postID string, tags ...string) error

func UpsertSearch

func UpsertSearch(_ context.Context, db BufferWriter, in repo.SearchInput) error

Types

type BufferWriter

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

type DBWriter

type DBWriter interface {
	Updater
	BufferWriter
}

type Index

type Index interface {
	Name() string
	Table() string
	AllColumnNames() []string
}

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 NewRepo

func NewRepo(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 Table

type Table interface {
	TableName() string
	AllColumnNames() []string
}

type Updater

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

Directories

Path Synopsis
Code generated by tablegen.
Code generated by tablegen.

Jump to

Keyboard shortcuts

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