spanner

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InsertUpdateOrDeleteStatement = "Calling DML Statement"
	InsertOrUpdateMutation        = "Calling Insert or Update Using Mutations"
	DeleteUsingMutations          = "Calling Delete Using Mutations"
	FilterAndExecuteBatch         = "Filter And Execute Batch"
)
View Source
const (
	CommitAPI              = "Commit"
	ExecuteBatchDMLAPI     = "ExecuteBatchDML"
	ExecuteStreamingSqlAPI = "ExecuteStreamingSql"
	UnknownOrMixedAPI      = ""
)

Variables

View Source
var NewSpannerClient = func(client *spanner.Client, logger *zap.Logger, responseHandler *responsehandler.TypeHandler, keyspaceFlatter bool, maxCommitDelay uint64, replayProtection bool) SpannerClientIface {
	return &SpannerClient{
		Client:           client,
		Logger:           logger,
		ResponseHandler:  responseHandler,
		KeyspaceFlatter:  keyspaceFlatter,
		MaxCommitDelay:   maxCommitDelay,
		ReplayProtection: replayProtection,
	}
}

Functions

This section is empty.

Types

type ErrorInfo

type ErrorInfo struct {
	Query string `json:"query"`
	Error string `json:"error"`
}

type FilterBatchResponse

type FilterBatchResponse struct {
	Queries               []*responsehandler.QueryMetadata // Filtered batch queries
	CanExecuteAsBatch     bool                             // This flag is used to run all queries in sequence when batch contains map update by key
	OnlyInserts           bool                             // This flag is used to run all queries as mutations when only INSERTS are available in the batch
	CanExecuteAsMutations bool                             // This flag is used to run all queries as mutations when only INSERTS are available in the batch
}

Response struct of filterBatch function

type SpannerClient

type SpannerClient struct {
	Client           *spanner.Client
	Logger           *zap.Logger
	ResponseHandler  *responsehandler.TypeHandler
	KeyspaceFlatter  bool
	MaxCommitDelay   uint64
	ReplayProtection bool
}

func (*SpannerClient) BuildCommitOptions

func (sc *SpannerClient) BuildCommitOptions() spanner.CommitOptions

BuildCommitOptions returns the commit options for Spanner transactions.

func (*SpannerClient) Close

func (sc *SpannerClient) Close() error

Close - Close the spanner client

func (*SpannerClient) DeleteUsingMutations

func (sc *SpannerClient) DeleteUsingMutations(ctx context.Context, query responsehandler.QueryMetadata) (*message.RowsResult, string, error)

func (*SpannerClient) FilterAndExecuteBatch

func (sc *SpannerClient) FilterAndExecuteBatch(ctx context.Context, queries []*responsehandler.QueryMetadata) (*message.VoidResult, string, error)

func (*SpannerClient) GetTableConfigs

GetTableConfigs - Get Table config from Spanner.

Parameters:

  • ctx: Context.
  • query: query metadata.

Returns: []tableConfig.TableMetaData (metadata of each table) and error.

func (*SpannerClient) InsertMutation

InsertOrUpdateMutation - Handle Insert Operation

Parameters:

  • ctx: Context.
  • query: query metadata.

Returns: message.RowsResult (supported response format to the cassandra client) and error.

func (*SpannerClient) InsertOrUpdateMutation

func (sc *SpannerClient) InsertOrUpdateMutation(ctx context.Context, query responsehandler.QueryMetadata) (*message.RowsResult, string, error)

InsertOrUpdateMutation - Handle Insert/Update/Delete Operation

Parameters:

  • ctx: Context.
  • query: query metadata.

Returns: message.RowsResult (supported response format to the cassandra client) and error.

func (*SpannerClient) InsertUpdateOrDeleteStatement

func (sc *SpannerClient) InsertUpdateOrDeleteStatement(ctx context.Context, query responsehandler.QueryMetadata) (*message.RowsResult, string, error)

InsertUpdateOrDeleteStatement - Handle Insert/Update/Delete Operation

Parameters:

  • ctx: Context.
  • query: query metadata.

Returns: message.RowsResult (supported response format to the cassandra client) and error.

func (*SpannerClient) SelectStatement

SelectStatement - Handle Select Operation

Parameters:

  • ctx: Context.
  • query: query metadata.

Returns: message.RowsResult (supported response format to the cassandra client) and error.

func (*SpannerClient) UpdateMapByKey

UpdateMapByKey - Handle Update Map By Key Operation with pattern column[?] = true/false first select data from the table and then update

Parameters:

  • ctx: Context.
  • query: query metadata.

Returns: message.RowsResult (supported response format to the cassandra client) and error.

type SpannerClientIface

type SpannerClientIface interface {
	SelectStatement(ctx context.Context, query responsehandler.QueryMetadata) (*message.RowsResult, string, error)
	InsertUpdateOrDeleteStatement(ctx context.Context, query responsehandler.QueryMetadata) (*message.RowsResult, string, error)
	Close() error
	InsertOrUpdateMutation(ctx context.Context, query responsehandler.QueryMetadata) (*message.RowsResult, string, error)
	DeleteUsingMutations(ctx context.Context, query responsehandler.QueryMetadata) (*message.RowsResult, string, error)
	UpdateMapByKey(ctx context.Context, query responsehandler.QueryMetadata) (*message.RowsResult, string, error)
	FilterAndExecuteBatch(ctx context.Context, queries []*responsehandler.QueryMetadata) (*message.VoidResult, string, error)
	GetTableConfigs(ctx context.Context, query responsehandler.QueryMetadata) (map[string]map[string]*tableConfig.Column, map[string][]tableConfig.Column, *SystemQueryMetadataCache, error)
}

type SystemQueryMetadataCache

type SystemQueryMetadataCache struct {
	KeyspaceSystemQueryMetadataCache map[primitive.ProtocolVersion][]message.Row
	TableSystemQueryMetadataCache    map[primitive.ProtocolVersion][]message.Row
	ColumnsSystemQueryMetadataCache  map[primitive.ProtocolVersion][]message.Row
}

Jump to

Keyboard shortcuts

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