Documentation
¶
Overview ¶
Package spannerr (pronounced Spanner R, or Spanner-er) provides session management and a simple interface for Google Cloud Spanner's REST API. If you are not on running your services on Google App Engine, you should just use the official Cloud Spanner (gRPC) client: https://godoc.org/cloud.google.com/go/spanner
Index ¶
- type Client
- type Param
- type Session
- func (s *Session) BeginTransaction(ctx context.Context, opts *spanner.BeginTransactionRequest) (*spanner.Transaction, error)
- func (s *Session) Commit(ctx context.Context, mutations []*spanner.Mutation, ...) (*spanner.CommitResponse, error)
- func (s *Session) ExecuteSQL(ctx context.Context, params []*Param, sql, queryMode string, ...) (*spanner.ResultSet, error)
- func (s *Session) Rollback(ctx context.Context, txID string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client allows users to manage sessions on Google Cloud Spanner.
func (*Client) AcquireSession ¶
AcquireSession will pull an existing session from the local cache. If the session cache is not full, it will create a new session and put it in the cache. Users must pass the Session to ReleaseSession when work is complete.
func (*Client) Close ¶
Close will attempt to end all existing sessions. If you have shutdown hooks available for your instance type, call this then. If you do not have shutdown hooks, the sessions made will be closed automatically after one hour of idle time: https://cloud.google.com/spanner/docs/sessions
type Param ¶
type Param struct { // Name is the name of the parameter used within the sql. Name string // Value is the value of the parameter to pass into the query. Value interface{} // Type will be used to populate the spanner.Type.Code field. More details // can be found here: https://godoc.org/google.golang.org/api/spanner/v1#Type Type string // ArrayElementType will be used to populate the spanner.Type.Code field of a // nested array type. More details can be found here: // https://godoc.org/google.golang.org/api/spanner/v1#Type ArrayElementType string }
Param contains the information required to pass a parameter to a Cloud Spanner query.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a live session on Google Cloud Spanner.
func (*Session) BeginTransaction ¶ added in v0.2.0
func (s *Session) BeginTransaction(ctx context.Context, opts *spanner.BeginTransactionRequest) (*spanner.Transaction, error)
BeginTransaction starts a new transaction.
func (*Session) Commit ¶
func (s *Session) Commit(ctx context.Context, mutations []*spanner.Mutation, opts *spanner.TransactionOptions, txID string) (*spanner.CommitResponse, error)
Commit commits a transaction. The request includes the mutations to be applied to rows in the database. Including opts signals a one-off query, whereas including txID signals this commit is part of a larger transaction. This function wraps https://godoc.org/google.golang.org/api/spanner/v1#ProjectsInstancesDatabasesSessionsService.Commit
func (*Session) ExecuteSQL ¶
func (s *Session) ExecuteSQL(ctx context.Context, params []*Param, sql, queryMode string, tx *spanner.TransactionSelector) (*spanner.ResultSet, error)
ExecuteSQL executes an SQL query, returning all rows in a single reply. It can be called within a transaction by including a TransactionSelector with its Id field set. This function wraps https://godoc.org/google.golang.org/api/spanner/v1#ProjectsInstancesDatabasesSessionsExecuteSqlCall