Documentation ¶
Index ¶
- Variables
- func BuildURL(project string, instance string, database *string) string
- func CollectRow[T any](iter *spanner.RowIterator, scan func(row *spanner.Row, item *T) error) (r T, _ error)
- func CollectRows[T any](iter *spanner.RowIterator, scan func(row *spanner.Row, item *T) error) (rs []T, _ error)
- func CreateDatabase(ctx context.Context, projectID, instanceID, databaseName string) error
- func CreateRandomTestingDatabaseName(n int) string
- func DSNFromURL(url string) string
- func EscapeIdentifier(s string) string
- func OpenUnique(ctx context.Context, connstr string, databasePrefix string) (*dbutil.TempDatabase, error)
- func ParseConnStr(full string) (project, instance string, database *string, err error)
- type EmulatorAdmin
- func (admin *EmulatorAdmin) Close() error
- func (admin *EmulatorAdmin) CreateDatabase(ctx context.Context, projectID, instanceID, databaseID string, ddls ...string) error
- func (admin *EmulatorAdmin) CreateInstance(ctx context.Context, projectID, instanceID string) error
- func (admin *EmulatorAdmin) DeleteInstance(ctx context.Context, projectID, instanceID string) error
- func (admin *EmulatorAdmin) DialDatabase(ctx context.Context, projectID, instanceID, databaseID string) (*spanner.Client, error)
- func (admin *EmulatorAdmin) DropDatabase(ctx context.Context, projectID, instanceID, databaseID string) error
- type IntValueDecoder
Constants ¶
This section is empty.
Variables ¶
var Error = errs.Class("spannerutil")
Error is error class for this package.
Functions ¶
func BuildURL ¶ added in v1.109.1
BuildURL takes necessary and optional connection string parameters to build a spanner URL.
func CollectRow ¶ added in v1.106.1
func CollectRow[T any](iter *spanner.RowIterator, scan func(row *spanner.Row, item *T) error) (r T, _ error)
CollectRow scans a single row into a slice.
func CollectRows ¶ added in v1.106.1
func CollectRows[T any](iter *spanner.RowIterator, scan func(row *spanner.Row, item *T) error) (rs []T, _ error)
CollectRows scans each row into a slice.
func CreateDatabase ¶ added in v1.109.1
CreateDatabase creates a schema in spanner with the given name.
func CreateRandomTestingDatabaseName ¶ added in v1.109.1
CreateRandomTestingDatabaseName creates a random schema name string.
func DSNFromURL ¶ added in v1.109.1
DSNFromURL takes in a Spanner URL and returns back the DSN that is used to connect with Spanner packages.
func EscapeIdentifier ¶ added in v1.109.1
EscapeIdentifier uses spanner escape characters to escape the given string.
func OpenUnique ¶ added in v1.109.1
func OpenUnique(ctx context.Context, connstr string, databasePrefix string) (*dbutil.TempDatabase, error)
OpenUnique opens a spanner database with a temporary unique schema, which will be cleaned up when closed. It is expected that this should normally be used by way of "storj.io/storj/shared/dbutil/tempdb".OpenUnique() instead of calling it directly.
Types ¶
type EmulatorAdmin ¶ added in v1.109.1
type EmulatorAdmin struct { HostPort string Instances *instance.InstanceAdminClient Databases *database.DatabaseAdminClient }
EmulatorAdmin provides facilities to communicate with the Spanner Emulator to create new instances and databases.
func OpenEmulatorAdmin ¶ added in v1.109.1
func OpenEmulatorAdmin(ctx context.Context, hostport string) (*EmulatorAdmin, error)
OpenEmulatorAdmin creates a new emulator admin that uses the specified endpoint.
func (*EmulatorAdmin) Close ¶ added in v1.109.1
func (admin *EmulatorAdmin) Close() error
Close closes the underlying clients.
func (*EmulatorAdmin) CreateDatabase ¶ added in v1.109.1
func (admin *EmulatorAdmin) CreateDatabase(ctx context.Context, projectID, instanceID, databaseID string, ddls ...string) error
CreateDatabase creates a new database with the specified name.
func (*EmulatorAdmin) CreateInstance ¶ added in v1.109.1
func (admin *EmulatorAdmin) CreateInstance(ctx context.Context, projectID, instanceID string) error
CreateInstance creates a new instance with the specified name.
func (*EmulatorAdmin) DeleteInstance ¶ added in v1.109.1
func (admin *EmulatorAdmin) DeleteInstance(ctx context.Context, projectID, instanceID string) error
DeleteInstance deletes an instance with the specified name.
func (*EmulatorAdmin) DialDatabase ¶ added in v1.109.1
func (admin *EmulatorAdmin) DialDatabase(ctx context.Context, projectID, instanceID, databaseID string) (*spanner.Client, error)
DialDatabase creates a new connection to the spanner instance.
func (*EmulatorAdmin) DropDatabase ¶ added in v1.109.1
func (admin *EmulatorAdmin) DropDatabase(ctx context.Context, projectID, instanceID, databaseID string) error
DropDatabase deletes the specified database.
type IntValueDecoder ¶
type IntValueDecoder[T inty] struct {
// contains filtered or unexported fields
}
IntValueDecoder is a type wrapping an int pointer so it can decode integer values from Spanner directly (Spanner prefers to work only in int64s).
func Int ¶
func Int[T inty](val *T) IntValueDecoder[T]
Int wraps a pointer to an int-based type in a type that can be decoded directly from Spanner.
In general, it is preferable to add EncodeSpanner/DecodeSpanner methods to our specialized int types, but this can be used for types we don't own or otherwise can't put methods on.
func (IntValueDecoder[T]) DecodeSpanner ¶
func (s IntValueDecoder[T]) DecodeSpanner(input any) error
DecodeSpanner decodes a value from a Spanner-stored type to the appropriate int type. It implements spanner.Decoder.