Documentation ¶
Index ¶
- func InitTransactionManager(transactionChannelBufferSize int, ...)
- type AckAction
- type Action
- type ActionNotFound
- type ActionStatus
- type CommitAction
- type CompleteTransaction
- type DiscardTransaction
- type EvictedTransaction
- type IntakeTransaction
- type MockTransactionManager
- func (ttm *MockTransactionManager) AcknowledgeAction(transactionID, actionID string)
- func (ttm *MockTransactionManager) CommitAction(transactionID, actionID string)
- func (ttm *MockTransactionManager) CompleteTransaction(transactionID string)
- func (ttm *MockTransactionManager) DiscardTransaction(transactionID, reason string)
- func (ttm *MockTransactionManager) GetActiveTransaction(string) (*IntakeTransaction, error)
- func (ttm *MockTransactionManager) GetCurrentTransaction() string
- func (ttm *MockTransactionManager) GetCurrentTransactionNotifyChannel() chan interface{}
- func (ttm *MockTransactionManager) GetCurrentTransactionState() *TransactionState
- func (ttm *MockTransactionManager) NextAction() interface{}
- func (ttm *MockTransactionManager) RejectAction(transactionID, actionID, reason string)
- func (ttm *MockTransactionManager) SetState(_, key string, value string)
- func (ttm *MockTransactionManager) Start()
- func (ttm *MockTransactionManager) StartTransaction(_ check.ID, TransactionID string, NotifyChannel chan interface{})
- func (ttm *MockTransactionManager) Stop()
- func (ttm *MockTransactionManager) TransactionCount() int
- type RejectAction
- type SetTransactionState
- type StartTransaction
- type StopTransactionManager
- type TransactionAPI
- type TransactionCompleted
- type TransactionManager
- type TransactionNotFound
- type TransactionState
- type TransactionStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitTransactionManager ¶
func InitTransactionManager(transactionChannelBufferSize int, tickerInterval, transactionTimeoutDuration, transactionEvictionDuration time.Duration)
InitTransactionManager ...
Types ¶
type AckAction ¶
type AckAction struct {
TransactionID, ActionID string
}
AckAction acknowledges an action for a given transaction.
type Action ¶
type Action struct { ActionID string CommittedTimestamp time.Time Status ActionStatus StatusUpdatedTimestamp time.Time }
Action represents a single operation in a checkmanager, which consists of one or more actions
type ActionNotFound ¶
type ActionNotFound struct {
TransactionID, ActionID string
}
ActionNotFound is triggered when trying to look up a non-existing action for a transaction in the transaction checkmanager
func (ActionNotFound) Error ¶
func (a ActionNotFound) Error() string
Error returns a string representation of the ActionNotFound error and implements Error.
type ActionStatus ¶
type ActionStatus int64
ActionStatus is an integer representing the state of the action
const ( // Committed is used to represent a Committed action Committed ActionStatus = iota // Acknowledged is used to represent an Acknowledged action. ie successfully "completed" action Acknowledged // Rejected is used to represent an Rejected action. ie unsuccessfully "completed" action Rejected )
func (ActionStatus) String ¶
func (state ActionStatus) String() string
String returns a string representation of ActionStatus
type CommitAction ¶
type CommitAction struct {
TransactionID, ActionID string
}
CommitAction is used to commit an action for a certain transaction.
type CompleteTransaction ¶
type CompleteTransaction struct { TransactionID string State *TransactionState }
CompleteTransaction completes a transaction. If all actions are acknowledges, the transaction is considered a success.
type DiscardTransaction ¶
type DiscardTransaction struct {
TransactionID, Reason string
}
DiscardTransaction rolls back a transaction and marks a transaction as a failure.
func (DiscardTransaction) Error ¶
func (r DiscardTransaction) Error() string
Error returns a string representing the DiscardTransaction.
type EvictedTransaction ¶
type EvictedTransaction struct {
TransactionID string
}
EvictedTransaction is triggered once a stale transaction is evicted.
type IntakeTransaction ¶
type IntakeTransaction struct { TransactionID string CheckID check.ID Status TransactionStatus Actions map[string]*Action // pointer to allow in-place mutation instead of setting the value again NotifyChannel chan interface{} LastUpdatedTimestamp time.Time State *TransactionState // the State of the TransactionState will be updated each time, no need for a pointer }
IntakeTransaction represents an intake checkmanager which consists of one or more actions
type MockTransactionManager ¶
type MockTransactionManager struct { TransactionActions chan interface{} // contains filtered or unexported fields }
MockTransactionManager is a mock implementation of the transaction manager for tests
func NewMockTransactionManager ¶
func NewMockTransactionManager() *MockTransactionManager
NewMockTransactionManager returns a handle on the global transactionbatcher Instance
func (*MockTransactionManager) AcknowledgeAction ¶
func (ttm *MockTransactionManager) AcknowledgeAction(transactionID, actionID string)
AcknowledgeAction sends a AckAction to the TransactionActions channel to be used in assertions
func (*MockTransactionManager) CommitAction ¶
func (ttm *MockTransactionManager) CommitAction(transactionID, actionID string)
CommitAction sends a CommitAction to the TransactionActions channel to be used in assertions
func (*MockTransactionManager) CompleteTransaction ¶
func (ttm *MockTransactionManager) CompleteTransaction(transactionID string)
CompleteTransaction sends a CompleteTransaction to the TransactionActions channel to be used in assertions
func (*MockTransactionManager) DiscardTransaction ¶
func (ttm *MockTransactionManager) DiscardTransaction(transactionID, reason string)
DiscardTransaction sends a DiscardTransaction to the TransactionActions channel to be used in assertions
func (*MockTransactionManager) GetActiveTransaction ¶
func (ttm *MockTransactionManager) GetActiveTransaction(string) (*IntakeTransaction, error)
GetActiveTransaction returns nil, nil
func (*MockTransactionManager) GetCurrentTransaction ¶
func (ttm *MockTransactionManager) GetCurrentTransaction() string
GetCurrentTransaction returns the current transaction
func (*MockTransactionManager) GetCurrentTransactionNotifyChannel ¶
func (ttm *MockTransactionManager) GetCurrentTransactionNotifyChannel() chan interface{}
GetCurrentTransactionNotifyChannel returns the currentTransactionNotifyChannel
func (*MockTransactionManager) GetCurrentTransactionState ¶
func (ttm *MockTransactionManager) GetCurrentTransactionState() *TransactionState
GetCurrentTransactionState returns the transactionState
func (*MockTransactionManager) NextAction ¶
func (ttm *MockTransactionManager) NextAction() interface{}
NextAction returns the next action from the TransactionActions channel to be used in assertions
func (*MockTransactionManager) RejectAction ¶
func (ttm *MockTransactionManager) RejectAction(transactionID, actionID, reason string)
RejectAction sends a RejectAction to the TransactionActions channel to be used in assertions
func (*MockTransactionManager) SetState ¶
func (ttm *MockTransactionManager) SetState(_, key string, value string)
SetState sets the mock transactionState to the given key + value
func (*MockTransactionManager) StartTransaction ¶
func (ttm *MockTransactionManager) StartTransaction(_ check.ID, TransactionID string, NotifyChannel chan interface{})
StartTransaction sets the current transaction value and updates the notify channel
func (*MockTransactionManager) Stop ¶
func (ttm *MockTransactionManager) Stop()
Stop resets the singleton init
func (*MockTransactionManager) TransactionCount ¶
func (ttm *MockTransactionManager) TransactionCount() int
TransactionCount return 0
type RejectAction ¶
type RejectAction struct {
TransactionID, ActionID, Reason string
}
RejectAction rejects an action for a given transaction. This results in a failed transaction.
type SetTransactionState ¶
type SetTransactionState struct {
TransactionID, Key, State string
}
SetTransactionState is used to set transaction state for a given transactionID and Key.
type StartTransaction ¶
type StartTransaction struct { CheckID check.ID TransactionID string NotifyChannel chan interface{} }
StartTransaction starts a transaction for a given checkID, with an optional OnComplete callback function.
type StopTransactionManager ¶
type StopTransactionManager struct{}
StopTransactionManager triggers the shutdown of the transaction checkmanager.
type TransactionAPI ¶
type TransactionAPI interface { GetActiveTransaction(transactionID string) (*IntakeTransaction, error) TransactionCount() int StartTransaction(CheckID check.ID, TransactionID string, NotifyChannel chan interface{}) CompleteTransaction(transactionID string) DiscardTransaction(transactionID, reason string) CommitAction(transactionID, actionID string) AcknowledgeAction(transactionID, actionID string) SetState(transactionID, key string, state string) RejectAction(transactionID, actionID, reason string) }
TransactionAPI contains the functions required for transactional behaviour
type TransactionCompleted ¶
type TransactionCompleted struct {
TransactionID string
}
TransactionCompleted is triggered when trying to look up a transaction that is already in a failed / succeeded state.
func (TransactionCompleted) Error ¶
func (t TransactionCompleted) Error() string
Error returns a string representation of the TransactionCompleted error and implements Error.
type TransactionManager ¶
type TransactionManager interface { Start() TransactionAPI Stop() }
TransactionManager encapsulates all the functionality of the transaction manager to keep track of transactions
func GetTransactionManager ¶
func GetTransactionManager() TransactionManager
GetTransactionManager returns a handle on the global transactionbatcher Instance
type TransactionNotFound ¶
type TransactionNotFound struct {
TransactionID string
}
TransactionNotFound is triggered when trying to look up a non-existing transaction in the transaction checkmanager
func (TransactionNotFound) Error ¶
func (t TransactionNotFound) Error() string
Error returns a string representation of the TransactionNotFound error and implements Error.
type TransactionState ¶
type TransactionState struct {
Key, State string
}
TransactionState keeps the state for a given key
type TransactionStatus ¶
type TransactionStatus int64
TransactionStatus is an integer representing the state of the transaction
const ( // InProgress is used to represent a InProgress transaction InProgress TransactionStatus = iota // Failed is used to represent a Failed transaction Failed // Succeeded is used to represent a Succeeded transaction Succeeded // Stale is used to represent a Stale transaction Stale )
func (TransactionStatus) String ¶
func (state TransactionStatus) String() string
String returns a string representation of TransactionStatus