services

package
v0.0.0-...-97f136a Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package services implements services for getting data from Spanner

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(ctx context.Context, tableName string, attrMap map[string]interface{}, condExpression string, m, expressionAttr map[string]interface{}, expr *models.UpdateExpressionCondition, oldRes map[string]interface{}) (map[string]interface{}, error)

Add checks the expression for converting the data

func BatchDelete

func BatchDelete(ctx context.Context, tableName string, keyMapArray []map[string]interface{}) error

BatchDelete service

func BatchGet

func BatchGet(ctx context.Context, tableName string, keyMapArray []map[string]interface{}) ([]map[string]interface{}, error)

BatchGet for batch operation for getting data

func BatchGetWithProjection

func BatchGetWithProjection(ctx context.Context, tableName string, keyMapArray []map[string]interface{}, projectionExpression string, expressionAttributeNames map[string]string) ([]map[string]interface{}, error)

BatchGetWithProjection from Spanner

func BatchPut

func BatchPut(ctx context.Context, tableName string, arrAttrMap []map[string]interface{}, spannerRow []map[string]interface{}) error

BatchPut writes bulk records to Spanner

func Del

func Del(ctx context.Context, tableName string, attrMap map[string]interface{}, condExpression string, expressionAttr map[string]interface{}, expr *models.UpdateExpressionCondition) (map[string]interface{}, error)

Del checks the expression for saving the data

func Delete

func Delete(ctx context.Context, tableName string, primaryKeyMap map[string]interface{}, condExpression string, attrMap map[string]interface{}, expr *models.UpdateExpressionCondition) error

Delete service

func ExecuteStatement

func ExecuteStatement(ctx context.Context, executeStatement models.ExecuteStatement) (map[string]interface{}, error)

ExecuteStatement service API handler function

func ExecuteStatementForDelete

func ExecuteStatementForDelete(ctx context.Context, executeStatement models.ExecuteStatement) (map[string]interface{}, error)

ExecuteStatementForDelete executes a delete statement on a Spanner database by converting a PartiQL delete statement to a Spanner compatible format and performing the delete operation.

Parameters: - ctx: The context for managing request-scoped values, cancellations, and timeouts. - executeStatement: Contains the PartiQL delete statement and the parameters for the deletion.

Returns: - map[string]interface{}: A map containing the result of the delete operation. - error: An error object, if any issues arise during the execution process.

func ExecuteStatementForInsert

func ExecuteStatementForInsert(ctx context.Context, executeStatement models.ExecuteStatement) (map[string]interface{}, error)

ExecuteStatementForInsert executes an insert statement on a Spanner database by converting a PartiQL insert statement to a Spanner compatible format and then performing the insert operation.

Parameters: - ctx: The context for managing request-scoped values, cancellations, and timeouts. - executeStatement: Contains the PartiQL insert statement and the attributes to be inserted.

Returns: - map[string]interface{}: A map containing the result of the insert operation. - error: An error object, if any issues arise during the execution process.

func ExecuteStatementForSelect

func ExecuteStatementForSelect(ctx context.Context, executeStatement models.ExecuteStatement) (map[string]interface{}, error)

ExecuteStatementForSelect executes a select statement on a Spanner database, converting a PartiQL statement to a Spanner statement.

Parameters: - ctx: Context for managing request-scoped values, cancellations, and timeouts. - executeStatement: Contains the PartiQL select statement and parameters to be executed.

Returns: - map[string]interface{}: A map containing the fetched items under the key "Items". - error: An error object, if any issues arise during the execution process.

func ExecuteStatementForUpdate

func ExecuteStatementForUpdate(ctx context.Context, executeStatement models.ExecuteStatement) (map[string]interface{}, error)

ExecuteStatementForUpdate executes an update statement on a Spanner database by converting a PartiQL update statement to a Spanner compatible format and performing the update operation.

Parameters: - ctx: The context for managing request-scoped values, cancellations, and timeouts. - executeStatement: Contains the PartiQL update statement and the parameters for the update.

Returns: - map[string]interface{}: A map containing the result of the update operation or nil if successful. - error: An error object, if any issues arise during the execution process.

func IsStreamEnabled

func IsStreamEnabled(tableName string) bool

IsStreamEnabled checks if a table is enabled for streaming or not

func MayIReadOrWrite

func MayIReadOrWrite(table string, IsMutation bool, operation string) bool

MayIReadOrWrite for checking the operation is allowed or not

func Put

func Put(ctx context.Context, tableName string, putObj map[string]interface{}, expr *models.UpdateExpressionCondition, conditionExp string, expressionAttr, oldRes map[string]interface{}, spannerRow map[string]interface{}) (map[string]interface{}, error)

Put writes an object to Spanner

func QueryAttributes

func QueryAttributes(ctx context.Context, query models.Query) (map[string]interface{}, string, error)

QueryAttributes from Spanner

func Remove

func Remove(ctx context.Context, tableName string, updateAttr models.UpdateAttr, actionValue string, expr *models.UpdateExpressionCondition, oldRes map[string]interface{}) (map[string]interface{}, error)

Remove for remove operation in update

func Scan

func Scan(ctx context.Context, scanData models.ScanMeta) (map[string]interface{}, error)

Scan service

func SetServiceInstance

func SetServiceInstance(s Service)

SetServiceInstance sets the service instance (for dependency injection)

func StartConfigManager

func StartConfigManager()

StartConfigManager starts config mangager for fetching the config manager data after certain time

func TransactWriteDelete

func TransactWriteDelete(ctx context.Context, tableName string, primaryKeyMap map[string]interface{}, condExpression string, attrMap map[string]interface{}, expr *models.UpdateExpressionCondition, txn *spanner.ReadWriteTransaction) (*spanner.Mutation, error)

TransactWriteDelete - This function is used to delete an item in a table. It takes the context of the request, the name of the table, the primary key map, the condition expression, the attribute map, the expression, and the transaction. It returns a mutation and an error.

Types

type Service

type Service interface {
	MayIReadOrWrite(tableName string, isWrite bool, user string) bool
	TransactGetItem(ctx context.Context, tableProjectionCols map[string][]string, pValues map[string]interface{}, sValues map[string]interface{}) ([]map[string]interface{}, error)
	TransactGetProjectionCols(ctx context.Context, transactGetMeta models.GetItemRequest) ([]string, []interface{}, []interface{}, error)
	TransactWritePut(ctx context.Context, tableName string, putObj map[string]interface{}, expr *models.UpdateExpressionCondition, conditionExp string, expressionAttr, oldRes map[string]interface{}, txn *spanner.ReadWriteTransaction) (map[string]interface{}, *spanner.Mutation, error)
	TransactWriteDel(ctx context.Context, tableName string, attrMap map[string]interface{}, condExpression string, expressionAttr map[string]interface{}, expr *models.UpdateExpressionCondition, txn *spanner.ReadWriteTransaction) (map[string]interface{}, *spanner.Mutation, error)
	TransactWriteAdd(ctx context.Context, tableName string, attrMap map[string]interface{}, condExpression string, m, expressionAttr map[string]interface{}, expr *models.UpdateExpressionCondition, oldRes map[string]interface{}, txn *spanner.ReadWriteTransaction) (map[string]interface{}, *spanner.Mutation, error)
	TransactWriteRemove(ctx context.Context, tableName string, updateAttr models.UpdateAttr, actionValue string, expr *models.UpdateExpressionCondition, oldRes map[string]interface{}, txn *spanner.ReadWriteTransaction) (map[string]interface{}, *spanner.Mutation, error)
	GetWithProjection(ctx context.Context, tableName string, primaryKeyMap map[string]interface{}, projectionExpression string, expressionAttributeNames map[string]string) (map[string]interface{}, map[string]interface{}, error)
}

func GetServiceInstance

func GetServiceInstance() Service

type Storage

type Storage interface {
	GetSpannerClient() (*spanner.Client, error)
	SpannerTransactGetItems(ctx context.Context, tableProjectionCols map[string][]string, pValues map[string]interface{}, sValues map[string]interface{}) ([]map[string]interface{}, error)
	SpannerTransactWritePut(ctx context.Context, table string, m map[string]interface{}, eval *models.Eval, expr *models.UpdateExpressionCondition, txn *spanner.ReadWriteTransaction, oldRes map[string]interface{}) (map[string]interface{}, *spanner.Mutation, error)
	SpannerGet(ctx context.Context, tableName string, pKeys, sKeys interface{}, projectionCols []string) (map[string]interface{}, map[string]interface{}, error)
	TransactWriteSpannerDel(ctx context.Context, table string, m map[string]interface{}, eval *models.Eval, expr *models.UpdateExpressionCondition, txn *spanner.ReadWriteTransaction) (*spanner.Mutation, error)
	TransactWriteSpannerAdd(ctx context.Context, table string, n map[string]interface{}, eval *models.Eval, expr *models.UpdateExpressionCondition, txn *spanner.ReadWriteTransaction) (map[string]interface{}, *spanner.Mutation, error)
	TransactWriteSpannerRemove(ctx context.Context, table string, m map[string]interface{}, eval *models.Eval, expr *models.UpdateExpressionCondition, colsToRemove []string, txn *spanner.ReadWriteTransaction) (*spanner.Mutation, error)
}

Jump to

Keyboard shortcuts

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