Documentation ¶
Index ¶
- Constants
- Variables
- func ProtocolExtensions() []string
- func ProtocolVersion() string
- type ATRLocation
- type AttemptContext
- func (c *AttemptContext) Commit() error
- func (c *AttemptContext) Defer() error
- func (c *AttemptContext) Get(collection *gocb.Collection, id string) (*GetResult, error)
- func (c *AttemptContext) GetOptional(collection *gocb.Collection, id string) (*GetResult, error)
- func (c *AttemptContext) Insert(collection *gocb.Collection, id string, value interface{}) (*GetResult, error)
- func (c *AttemptContext) Internal() *InternalAttemptContext
- func (c *AttemptContext) Query(statement string, options *QueryOptions) (*QueryResult, error)
- func (c *AttemptContext) Remove(doc *GetResult) error
- func (c *AttemptContext) Replace(doc *GetResult, value interface{}) (*GetResult, error)
- func (c *AttemptContext) Rollback() error
- type AttemptFunc
- type AttemptState
- type Cleaner
- type CleanupAttempt
- type CleanupHooks
- type CleanupRequest
- type ClientRecordDetails
- type ClientRecordHooks
- type Config
- type DocRecord
- type DurabilityLevel
- type ForwardCompatibilityEntry
- type GetResult
- type InternalAttemptContext
- type LostTransactionCleaner
- type PerTransactionConfig
- type PerTransactionQueryConfig
- type ProcessATRStats
- type QueryConfig
- type QueryMetaData
- type QueryMetrics
- type QueryOptions
- type QueryResult
- type QueryStatus
- type QueryWarning
- type Result
- type SerializedContext
- type SingleQueryTransactionConfig
- type SingleQueryTransactionResult
- type TransactionCommitAmbiguousError
- type TransactionExpiredError
- type TransactionFailedError
- type TransactionFailedPostCommit
- type TransactionHooks
- type TransactionOperationFailedError
- func (tfe TransactionOperationFailedError) Error() string
- func (tfe *TransactionOperationFailedError) ErrorClass() coretxns.ErrorClass
- func (tfe TransactionOperationFailedError) Retry() bool
- func (tfe TransactionOperationFailedError) Rollback() bool
- func (tfe TransactionOperationFailedError) ToRaise() coretxns.ErrorReason
- func (tfe TransactionOperationFailedError) Unwrap() error
- type Transactions
- func (t *Transactions) Close() error
- func (t *Transactions) Commit(serialized SerializedContext, perConfig *PerTransactionConfig) error
- func (t *Transactions) Internal() *TransactionsInternal
- func (t *Transactions) Query(statement string, options *SingleQueryTransactionConfig) (*SingleQueryTransactionResult, error)
- func (t *Transactions) Rollback(serialized SerializedContext, perConfig *PerTransactionConfig) error
- func (t *Transactions) Run(logicFn AttemptFunc, perConfig *PerTransactionConfig) (*Result, error)
- type TransactionsInternal
Constants ¶
const ( // DurabilityLevelUnknown indicates to use the default level. DurabilityLevelUnknown = DurabilityLevel(coretxns.DurabilityLevelUnknown) // DurabilityLevelNone indicates that no durability is needed. DurabilityLevelNone = DurabilityLevel(coretxns.DurabilityLevelNone) // DurabilityLevelMajority indicates the operation must be replicated to the majority. DurabilityLevelMajority = DurabilityLevel(coretxns.DurabilityLevelMajority) // DurabilityLevelMajorityAndPersistToActive indicates the operation must be replicated // to the majority and persisted to the active server. DurabilityLevelMajorityAndPersistToActive = DurabilityLevel(coretxns.DurabilityLevelMajorityAndPersistToActive) // DurabilityLevelPersistToMajority indicates the operation must be persisted to the active server. DurabilityLevelPersistToMajority = DurabilityLevel(coretxns.DurabilityLevelPersistToMajority) )
const ( AttemptStateNothingWritten = AttemptState(coretxns.AttemptStateNothingWritten) AttemptStatePending = AttemptState(coretxns.AttemptStatePending) AttemptStateCommitting = AttemptState(coretxns.AttemptStateCommitting) AttemptStateCommitted = AttemptState(coretxns.AttemptStateCommitted) AttemptStateCompleted = AttemptState(coretxns.AttemptStateCompleted) AttemptStateAborted = AttemptState(coretxns.AttemptStateAborted) AttemptStateRolledBack = AttemptState(coretxns.AttemptStateRolledBack) )
Variables ¶
var ( // ErrOther indicates an non-specific error has occured. ErrOther = coretxns.ErrOther // ErrTransient indicates a transient error occured which may succeed at a later point in time. ErrTransient = coretxns.ErrTransient // ErrWriteWriteConflict indicates that another transaction conflicted with this one. ErrWriteWriteConflict = coretxns.ErrWriteWriteConflict // ErrHard indicates that an unrecoverable error occured. ErrHard = coretxns.ErrHard // ErrAmbiguous indicates that a failure occured but the outcome was not known. ErrAmbiguous = coretxns.ErrAmbiguous // ErrAtrFull indicates that the ATR record was too full to accept a new mutation. ErrAtrFull = coretxns.ErrAtrFull // ErrAttemptExpired indicates an attempt expired ErrAttemptExpired = coretxns.ErrAttemptExpired // ErrAtrNotFound indicates that an expected ATR document was missing ErrAtrNotFound = coretxns.ErrAtrNotFound // ErrAtrEntryNotFound indicates that an expected ATR entry was missing ErrAtrEntryNotFound = coretxns.ErrAtrEntryNotFound // ErrDocAlreadyInTransaction indicates that a document is already in a transaction. ErrDocAlreadyInTransaction = coretxns.ErrDocAlreadyInTransaction // ErrTransactionAbortedExternally indicates the transaction was aborted externally. ErrTransactionAbortedExternally = coretxns.ErrTransactionAbortedExternally // ErrTransactionAbortedExternally indicates the transaction was aborted externally. ErrPreviousOperationFailed = coretxns.ErrPreviousOperationFailed // ErrForwardCompatibilityFailure indicates an operation failed due to involving a document in another transaction // which contains features this transaction does not support. ErrForwardCompatibilityFailure = coretxns.ErrForwardCompatibilityFailure // ErrIllegalState is used for when a transaction enters an illegal State. ErrIllegalState = coretxns.ErrIllegalState ErrDocumentNotFound = coretxns.ErrDocumentNotFound ErrDocumentAlreadyExists = coretxns.ErrDocumentAlreadyExists ErrAttemptNotFoundOnQuery = errors.New("attempt not found on query") ErrCasMismatch = coretxns.ErrCasMismatch )
Functions ¶
func ProtocolExtensions ¶
func ProtocolExtensions() []string
ProtocolExtensions returns a list strings representing the various features that this specific version of the library supports within its protocol version.
func ProtocolVersion ¶
func ProtocolVersion() string
ProtocolVersion returns the protocol version that this library supports.
Types ¶
type ATRLocation ¶
ATRLocation specifies a specific location where ATR entries should be placed when performing transactions.
type AttemptContext ¶
type AttemptContext struct {
// contains filtered or unexported fields
}
AttemptContext represents a single attempt to execute a transaction.
func (*AttemptContext) Commit ¶
func (c *AttemptContext) Commit() error
Commit will attempt to commit the transaction in its entirety.
func (*AttemptContext) Defer ¶
func (c *AttemptContext) Defer() error
Defer serializes the transaction to enable it to be completed at a later point in time. VOLATILE: This API is subject to change at any time.
func (*AttemptContext) Get ¶
func (c *AttemptContext) Get(collection *gocb.Collection, id string) (*GetResult, error)
Get will attempt to fetch a document, and fail the transaction if it does not exist.
func (*AttemptContext) GetOptional ¶
func (c *AttemptContext) GetOptional(collection *gocb.Collection, id string) (*GetResult, error)
GetOptional will attempt to fetch a document, and return nil if it does not exist.
func (*AttemptContext) Insert ¶
func (c *AttemptContext) Insert(collection *gocb.Collection, id string, value interface{}) (*GetResult, error)
Insert will insert a new document, failing if the document already exists.
func (*AttemptContext) Internal ¶
func (c *AttemptContext) Internal() *InternalAttemptContext
Internal is used for internal dealings. Internal: This should never be used and is not supported.
func (*AttemptContext) Query ¶
func (c *AttemptContext) Query(statement string, options *QueryOptions) (*QueryResult, error)
func (*AttemptContext) Remove ¶
func (c *AttemptContext) Remove(doc *GetResult) error
Remove will delete a document.
func (*AttemptContext) Replace ¶
func (c *AttemptContext) Replace(doc *GetResult, value interface{}) (*GetResult, error)
Replace will replace the contents of a document, failing if the document does not already exist.
func (*AttemptContext) Rollback ¶
func (c *AttemptContext) Rollback() error
Rollback will undo all changes related to a transaction.
type AttemptFunc ¶
type AttemptFunc func(*AttemptContext) error
type AttemptState ¶
type AttemptState int
type Cleaner ¶
type Cleaner interface { AddRequest(req *CleanupRequest) bool PopRequest() *CleanupRequest ForceCleanupQueue() []CleanupAttempt QueueLength() int32 CleanupAttempt(bucket *gocb.Bucket, isRegular bool, req *CleanupRequest) CleanupAttempt Close() }
Cleaner is responsible for performing cleanup of completed transactions. Internal: This should never be used and is not supported.
func NewCleaner ¶
func NewCleaner(agentProvider coretxns.BucketAgentProviderFn, config *Config) Cleaner
NewCleaner returns a Cleaner implementation. Internal: This should never be used and is not supported.
type CleanupAttempt ¶
type CleanupAttempt struct { Success bool IsReqular bool AttemptID string AtrID string AtrCollectionName string AtrScopeName string AtrBucketName string Request *CleanupRequest }
CleanupAttempt represents the result of running cleanup for a transaction attempt. Internal: This should never be used and is not supported.
type CleanupHooks ¶
type CleanupHooks interface { BeforeATRGet(id string) error BeforeDocGet(id string) error BeforeRemoveLinks(id string) error BeforeCommitDoc(id string) error BeforeRemoveDocStagedForRemoval(id string) error BeforeRemoveDoc(id string) error BeforeATRRemove(id string) error }
CleanupHooks provides a number of internal hooks used for testing. Internal: This should never be used and is not supported.
type CleanupRequest ¶
type CleanupRequest struct { AttemptID string AtrID string AtrCollectionName string AtrScopeName string AtrBucketName string Inserts []DocRecord Replaces []DocRecord Removes []DocRecord State AttemptState ForwardCompat map[string][]ForwardCompatibilityEntry }
CleanupRequest represents a complete transaction attempt that requires cleanup. Internal: This should never be used and is not supported.
type ClientRecordDetails ¶
type ClientRecordDetails struct { NumActiveClients int IndexOfThisClient int ClientIsNew bool ExpiredClientIDs []string NumExistingClients int NumExpiredClients int OverrideEnabled bool OverrideActive bool OverrideExpiresCas int64 CasNowNanos int64 AtrsHandledByClient []string CheckAtrEveryNMillis int ClientUUID string }
ClientRecordDetails is the result of processing a client record. Internal: This should never be used and is not supported.
type ClientRecordHooks ¶
type ClientRecordHooks interface { BeforeCreateRecord() error BeforeRemoveClient() error BeforeUpdateCAS() error BeforeGetRecord() error BeforeUpdateRecord() error }
ClientRecordHooks provides a number of internal hooks used for testing. Internal: This should never be used and is not supported.
type Config ¶
type Config struct { // MetadataCollection specifies a specific location to place meta-data. MetadataCollection *gocb.Collection // ExpirationTime sets the maximum time that transactions created // by this Transactions object can run for, before expiring. ExpirationTime time.Duration // DurabilityLevel specifies the durability level that should be used // for all write operations performed by this Transactions object. DurabilityLevel DurabilityLevel // KeyValueTimeout specifies the default timeout used for all KV writes. KeyValueTimeout time.Duration // CleanupWindow specifies how often to the cleanup process runs // attempting to garbage collection transactions that have failed but // were not cleaned up by the previous client. CleanupWindow time.Duration // CleanupClientAttempts controls where any transaction attempts made // by this client are automatically removed. CleanupClientAttempts bool // CleanupLostAttempts controls where a background process is created // to cleanup any ‘lost’ transaction attempts. CleanupLostAttempts bool // CleanupQueueSize controls the maximum queue size for the cleanup thread. CleanupQueueSize uint32 // QueryConfig specifies any query configuration to use in transactions. QueryConfig QueryConfig // Internal specifies a set of options for internal use. // Internal: This should never be used and is not supported. Internal struct { Hooks TransactionHooks CleanupHooks CleanupHooks ClientRecordHooks ClientRecordHooks NumATRs int } }
Config specifies various tunable options related to transactions.
type DocRecord ¶
DocRecord represents an individual document operation requiring cleanup. Internal: This should never be used and is not supported.
type DurabilityLevel ¶
type DurabilityLevel uint8
DurabilityLevel specifies the level of synchronous replication to use.
type ForwardCompatibilityEntry ¶
type ForwardCompatibilityEntry struct { ProtocolVersion string `json:"p,omitempty"` ProtocolExtension string `json:"e,omitempty"` Behaviour string `json:"b,omitempty"` RetryInterval int `json:"ra,omitempty"` }
ForwardCompatibilityEntry represents a forward compatibility entry. Internal: This should never be used and is not supported.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult represents the result of a Get operation which was performed.
type InternalAttemptContext ¶
type InternalAttemptContext struct {
// contains filtered or unexported fields
}
InternalAttemptContext is used for internal dealings. Internal: This should never be used and is not supported.
func (*InternalAttemptContext) IsExpired ¶
func (iac *InternalAttemptContext) IsExpired() bool
type LostTransactionCleaner ¶
type LostTransactionCleaner interface { ProcessATR(bucket *gocb.Bucket, collection, scope, atrID string) ([]CleanupAttempt, ProcessATRStats) ProcessClient(bucket *gocb.Bucket, collection, scope, clientUUID string) (*ClientRecordDetails, error) RemoveClient(uuid string) error Close() }
LostTransactionCleaner is responsible for performing cleanup of lost transactions. Internal: This should never be used and is not supported.
func NewLostCleanup ¶
func NewLostCleanup(agentProvider coretxns.BucketAgentProviderFn, locationProvider coretxns.LostCleanupATRLocationProviderFn, config *Config) LostTransactionCleaner
NewLostCleanup returns a LostCleanup implementation. Internal: This should never be used and is not supported.
type PerTransactionConfig ¶
type PerTransactionConfig struct { // DurabilityLevel specifies the durability level that should be used // for all write operations performed by this transaction. DurabilityLevel DurabilityLevel ExpirationTime time.Duration QueryConfig PerTransactionQueryConfig }
PerTransactionConfig specifies options which can be overridden on a per transaction basis.
type PerTransactionQueryConfig ¶
type PerTransactionQueryConfig struct {
ScanConsistency gocb.QueryScanConsistency
}
PerTransactionQueryConfig specifies query options which can be overridden on a per transaction basis.
type ProcessATRStats ¶
ProcessATRStats is the stats recorded when running a ProcessATR request. Internal: This should never be used and is not supported.
type QueryConfig ¶
type QueryConfig struct {
ScanConsistency gocb.QueryScanConsistency
}
QueryConfig specifies various tunable query options related to transactions.
type QueryMetaData ¶
type QueryMetaData struct { RequestID string ClientContextID string Status QueryStatus Metrics QueryMetrics Signature interface{} Warnings []QueryWarning Profile interface{} }
QueryMetaData provides access to the meta-data properties of a query result.
type QueryMetrics ¶
type QueryMetrics struct { ElapsedTime time.Duration ExecutionTime time.Duration ResultCount uint64 ResultSize uint64 MutationCount uint64 SortCount uint64 ErrorCount uint64 WarningCount uint64 }
QueryMetrics encapsulates various metrics gathered during a queries execution.
type QueryOptions ¶
type QueryOptions struct { ScanConsistency gocb.QueryScanConsistency Profile gocb.QueryProfileMode // ScanCap is the maximum buffered channel size between the indexer connectionManager and the query service for index scans. ScanCap uint32 // PipelineBatch controls the number of items execution operators can batch for Fetch from the KV. PipelineBatch uint32 // PipelineCap controls the maximum number of items each execution operator can buffer between various operators. PipelineCap uint32 // ScanWait is how long the indexer is allowed to wait until it can satisfy ScanConsistency/ConsistentWith criteria. ScanWait time.Duration Readonly bool // ClientContextID provides a unique ID for this query which can be used matching up requests between connectionManager and // server. If not provided will be assigned a uuid value. ClientContextID string PositionalParameters []interface{} NamedParameters map[string]interface{} // FlexIndex tells the query engine to use a flex index (utilizing the search service). FlexIndex bool // Raw provides a way to provide extra parameters in the request body for the query. Raw map[string]interface{} Prepared bool Scope *gocb.Scope }
type QueryResult ¶
type QueryResult struct {
// contains filtered or unexported fields
}
QueryResult allows access to the results of a query.
func (*QueryResult) Close ¶
func (r *QueryResult) Close() error
Close marks the results as closed, returning any errors that occurred during reading the results.
func (*QueryResult) Err ¶
func (r *QueryResult) Err() error
Err returns any errors that have occurred on the stream
func (*QueryResult) MetaData ¶
func (r *QueryResult) MetaData() (*QueryMetaData, error)
MetaData returns any meta-data that was available from this query. Note that the meta-data will only be available once the object has been closed (either implicitly or explicitly).
func (*QueryResult) Next ¶
func (r *QueryResult) Next() bool
Next assigns the next result from the results into the value pointer, returning whether the read was successful.
func (*QueryResult) One ¶
func (r *QueryResult) One(valuePtr interface{}) error
One assigns the first value from the results into the value pointer. It will close the results but not before iterating through all remaining results, as such this should only be used for very small resultsets - ideally of, at most, length 1.
func (*QueryResult) Row ¶
func (r *QueryResult) Row(valuePtr interface{}) error
Row returns the contents of the current row
type QueryStatus ¶
type QueryStatus string
QueryStatus provides information about the current status of a query.
const ( // QueryStatusRunning indicates the query is still running QueryStatusRunning QueryStatus = QueryStatus(gocb.QueryStatusRunning) // QueryStatusSuccess indicates the query was successful. QueryStatusSuccess QueryStatus = QueryStatus(gocb.QueryStatusSuccess) // QueryStatusErrors indicates a query completed with errors. QueryStatusErrors QueryStatus = QueryStatus(gocb.QueryStatusErrors) // QueryStatusCompleted indicates a query has completed. QueryStatusCompleted QueryStatus = QueryStatus(gocb.QueryStatusCompleted) // QueryStatusStopped indicates a query has been stopped. QueryStatusStopped QueryStatus = QueryStatus(gocb.QueryStatusStopped) // QueryStatusTimeout indicates a query timed out. QueryStatusTimeout QueryStatus = QueryStatus(gocb.QueryStatusTimeout) // QueryStatusClosed indicates that a query was closed. QueryStatusClosed QueryStatus = QueryStatus(gocb.QueryStatusClosed) // QueryStatusFatal indicates that a query ended with a fatal error. QueryStatusFatal QueryStatus = QueryStatus(gocb.QueryStatusFatal) // QueryStatusAborted indicates that a query was aborted. QueryStatusAborted QueryStatus = QueryStatus(gocb.QueryStatusAborted) // QueryStatusUnknown indicates that the query status is unknown. QueryStatusUnknown QueryStatus = QueryStatus(gocb.QueryStatusUnknown) )
type QueryWarning ¶
QueryWarning encapsulates any warnings returned by a query.
type Result ¶
type Result struct { // TransactionID represents the UUID assigned to this transaction TransactionID string // UnstagingComplete indicates whether the transaction was succesfully // unstaged, or if a later cleanup job will be responsible. UnstagingComplete bool // Serialized represents the serialized data from this transaction if // the transaction was serialized as opposed to being executed. Serialized *SerializedContext }
Result represents the result of a transaction which was executed.
type SerializedContext ¶
type SerializedContext struct { }
SerializedContext represents a transaction which has been serialized for resumption at a later point in time.
func (*SerializedContext) EncodeAsBytes ¶
func (c *SerializedContext) EncodeAsBytes() []byte
EncodeAsBytes will encode this SerializedContext to a set of bytes which can be decoded later to resume the transaction.
func (*SerializedContext) EncodeAsString ¶
func (c *SerializedContext) EncodeAsString() string
EncodeAsString will encode this SerializedContext to a string which can be decoded later to resume the transaction.
type SingleQueryTransactionConfig ¶
type SingleQueryTransactionConfig struct { QueryOptions QueryOptions DurabilityLevel DurabilityLevel ExpirationTime time.Duration }
SingleQueryTransactionConfig specifies various tunable query options related to single query transactions.
type SingleQueryTransactionResult ¶
type SingleQueryTransactionResult struct {
// contains filtered or unexported fields
}
SingleQueryTransactionResult allows access to the results of a single query transaction.
func (*SingleQueryTransactionResult) QueryResult ¶
func (qr *SingleQueryTransactionResult) QueryResult() *QueryResult
QueryResult returns the result of the query.
func (*SingleQueryTransactionResult) UnstagingComplete ¶
func (qr *SingleQueryTransactionResult) UnstagingComplete() bool
UnstagingComplete returns whether all documents were successfully unstaged (committed).
This will only return true if the transaction reached the COMMIT point and then went on to reach the COMPLETE point.
It will be false for transactions that: - Rolled back - Were read-only
type TransactionCommitAmbiguousError ¶
type TransactionCommitAmbiguousError struct {
// contains filtered or unexported fields
}
func (TransactionCommitAmbiguousError) Error ¶
func (tfe TransactionCommitAmbiguousError) Error() string
func (TransactionCommitAmbiguousError) Result ¶
func (tfe TransactionCommitAmbiguousError) Result() *Result
Internal: This should never be used and is not supported.
func (TransactionCommitAmbiguousError) Unwrap ¶
func (tfe TransactionCommitAmbiguousError) Unwrap() error
type TransactionExpiredError ¶
type TransactionExpiredError struct {
// contains filtered or unexported fields
}
func (TransactionExpiredError) Error ¶
func (tfe TransactionExpiredError) Error() string
func (TransactionExpiredError) Result ¶
func (tfe TransactionExpiredError) Result() *Result
Internal: This should never be used and is not supported.
func (TransactionExpiredError) Unwrap ¶
func (tfe TransactionExpiredError) Unwrap() error
type TransactionFailedError ¶
type TransactionFailedError struct {
// contains filtered or unexported fields
}
func (TransactionFailedError) Error ¶
func (tfe TransactionFailedError) Error() string
func (TransactionFailedError) Result ¶
func (tfe TransactionFailedError) Result() *Result
Internal: This should never be used and is not supported.
func (TransactionFailedError) Unwrap ¶
func (tfe TransactionFailedError) Unwrap() error
type TransactionFailedPostCommit ¶
type TransactionFailedPostCommit struct {
// contains filtered or unexported fields
}
func (TransactionFailedPostCommit) Error ¶
func (tfe TransactionFailedPostCommit) Error() string
func (TransactionFailedPostCommit) Result ¶
func (tfe TransactionFailedPostCommit) Result() *Result
Internal: This should never be used and is not supported.
func (TransactionFailedPostCommit) Unwrap ¶
func (tfe TransactionFailedPostCommit) Unwrap() error
type TransactionHooks ¶
type TransactionHooks interface { BeforeATRCommit(ctx AttemptContext) error AfterATRCommit(ctx AttemptContext) error BeforeDocCommitted(ctx AttemptContext, docID string) error BeforeRemovingDocDuringStagedInsert(ctx AttemptContext, docID string) error BeforeRollbackDeleteInserted(ctx AttemptContext, docID string) error AfterDocCommittedBeforeSavingCAS(ctx AttemptContext, docID string) error AfterDocCommitted(ctx AttemptContext, docID string) error BeforeStagedInsert(ctx AttemptContext, docID string) error BeforeStagedRemove(ctx AttemptContext, docID string) error BeforeStagedReplace(ctx AttemptContext, docID string) error BeforeDocRemoved(ctx AttemptContext, docID string) error BeforeDocRolledBack(ctx AttemptContext, docID string) error AfterDocRemovedPreRetry(ctx AttemptContext, docID string) error AfterDocRemovedPostRetry(ctx AttemptContext, docID string) error AfterGetComplete(ctx AttemptContext, docID string) error AfterStagedReplaceComplete(ctx AttemptContext, docID string) error AfterStagedRemoveComplete(ctx AttemptContext, docID string) error AfterStagedInsertComplete(ctx AttemptContext, docID string) error AfterRollbackReplaceOrRemove(ctx AttemptContext, docID string) error AfterRollbackDeleteInserted(ctx AttemptContext, docID string) error BeforeCheckATREntryForBlockingDoc(ctx AttemptContext, docID string) error BeforeDocGet(ctx AttemptContext, docID string) error BeforeGetDocInExistsDuringStagedInsert(ctx AttemptContext, docID string) error BeforeRemoveStagedInsert(ctx AttemptContext, docID string) error AfterRemoveStagedInsert(ctx AttemptContext, docID string) error AfterDocsCommitted(ctx AttemptContext) error AfterDocsRemoved(ctx AttemptContext) error AfterATRPending(ctx AttemptContext) error BeforeATRPending(ctx AttemptContext) error BeforeATRComplete(ctx AttemptContext) error BeforeATRRolledBack(ctx AttemptContext) error AfterATRComplete(ctx AttemptContext) error BeforeATRAborted(ctx AttemptContext) error AfterATRAborted(ctx AttemptContext) error AfterATRRolledBack(ctx AttemptContext) error BeforeATRCommitAmbiguityResolution(ctx AttemptContext) error RandomATRIDForVbucket(ctx AttemptContext) (string, error) HasExpiredClientSideHook(ctx AttemptContext, stage string, vbID string) (bool, error) BeforeQuery(ctx AttemptContext, statement string) error AfterQuery(ctx AttemptContext, statement string) error }
TransactionHooks provides a number of internal hooks used for testing. Internal: This should never be used and is not supported.
type TransactionOperationFailedError ¶
type TransactionOperationFailedError struct {
// contains filtered or unexported fields
}
TransactionOperationFailedError is used when a transaction operation fails. Internal: This should never be used and is not supported.
func (TransactionOperationFailedError) Error ¶
func (tfe TransactionOperationFailedError) Error() string
func (*TransactionOperationFailedError) ErrorClass ¶
func (tfe *TransactionOperationFailedError) ErrorClass() coretxns.ErrorClass
ErrorClass is the class of error which caused this error.
func (TransactionOperationFailedError) Retry ¶
func (tfe TransactionOperationFailedError) Retry() bool
Retry signals whether a new attempt should be made at rollback.
func (TransactionOperationFailedError) Rollback ¶
func (tfe TransactionOperationFailedError) Rollback() bool
Rollback signals whether the attempt should be auto-rolled back.
func (TransactionOperationFailedError) ToRaise ¶
func (tfe TransactionOperationFailedError) ToRaise() coretxns.ErrorReason
ToRaise signals which error type should be raised to the application.
func (TransactionOperationFailedError) Unwrap ¶
func (tfe TransactionOperationFailedError) Unwrap() error
type Transactions ¶
type Transactions struct {
// contains filtered or unexported fields
}
func Init ¶
func Init(cluster *gocb.Cluster, config *Config) (*Transactions, error)
Init will initialize the transactions library and return a Transactions object which can be used to perform transactions.
func (*Transactions) Close ¶
func (t *Transactions) Close() error
Close will shut down this Transactions object, shutting down all background tasks associated with it.
func (*Transactions) Commit ¶
func (t *Transactions) Commit(serialized SerializedContext, perConfig *PerTransactionConfig) error
Commit will commit a previously prepared and serialized transaction.
func (*Transactions) Internal ¶
func (t *Transactions) Internal() *TransactionsInternal
Internal returns an TransactionsInternal object which can be used for specialized internal use cases.
func (*Transactions) Query ¶
func (t *Transactions) Query(statement string, options *SingleQueryTransactionConfig) (*SingleQueryTransactionResult, error)
func (*Transactions) Rollback ¶
func (t *Transactions) Rollback(serialized SerializedContext, perConfig *PerTransactionConfig) error
Rollback will commit a previously prepared and serialized transaction.
func (*Transactions) Run ¶
func (t *Transactions) Run(logicFn AttemptFunc, perConfig *PerTransactionConfig) (*Result, error)
Run runs a lambda to perform a number of operations as part of a singular transaction.
type TransactionsInternal ¶
type TransactionsInternal struct {
// contains filtered or unexported fields
}
TransactionsInternal exposes internal methods that are useful for testing and/or other forms of internal use.
func (*TransactionsInternal) CleanupQueueLength ¶
func (t *TransactionsInternal) CleanupQueueLength() int32
CleanupQueueLength returns the current length of the client cleanup queue.
func (*TransactionsInternal) ClientCleanupEnabled ¶
func (t *TransactionsInternal) ClientCleanupEnabled() bool
ClientCleanupEnabled returns whether the client cleanup process is enabled.
func (*TransactionsInternal) ForceCleanupQueue ¶
func (t *TransactionsInternal) ForceCleanupQueue() []CleanupAttempt
ForceCleanupQueue forces the transactions client cleanup queue to drain without waiting for expirations.