Documentation ¶
Index ¶
Constants ¶
const ( // ErrTransactionBootstrap error when bootstrap fails. ErrTransactionBootstrap = errors.Error("failed to bootstrap transactions") // BootstrappedRepo is the key mapped to transactions.Repository. BootstrappedRepo = "BootstrappedRepo" // BootstrappedService is the key to mapped transactions.Service BootstrappedService = "BootstrappedService" )
const ( // ErrTransactionMissing error when transaction doesn't exist in Repository. ErrTransactionMissing = errors.Error("transaction doesn't exist") // ErrKeyConstructionFailed error when the key construction failed. ErrKeyConstructionFailed = errors.Error("failed to construct transaction key") )
const ErrInvalidAccountID = errors.Error("Invalid Tenant ID")
ErrInvalidAccountID error for Invalid account ID.
const ErrInvalidTransactionID = errors.Error("Invalid Transaction ID")
ErrInvalidTransactionID error for Invalid transaction ID.
const (
// TxIDParam maps transaction ID in the kwargs.
TxIDParam = "transactionID"
)
Variables ¶
This section is empty.
Functions ¶
func GRPCHandler ¶
GRPCHandler returns an implementation of the TransactionServiceServer
Types ¶
type BaseTask ¶
type BaseTask struct { TxID uuid.UUID TxService Service }
BaseTask holds the required details and helper functions for tasks to update transactions. should be embedded into the task
func (*BaseTask) ParseTransactionID ¶
ParseTransactionID parses txID.
type Bootstrapper ¶
type Bootstrapper struct{}
Bootstrapper implements bootstrap.Bootstrapper.
func (Bootstrapper) Bootstrap ¶
func (b Bootstrapper) Bootstrap(ctx map[string]interface{}) error
Bootstrap adds transaction.Repository into context.
type Repository ¶
type Repository interface { Get(cid identity.CentID, id uuid.UUID) (*Transaction, error) Save(transaction *Transaction) error }
Repository can be implemented by a type that handles storage for transactions.
func NewRepository ¶
func NewRepository(repo storage.Repository) Repository
NewRepository registers the the transaction model and returns the an implementation of the Repository.
type Service ¶
type Service interface { CreateTransaction(accountID identity.CentID, desc string) (*Transaction, error) GetTransaction(accountID identity.CentID, id uuid.UUID) (*Transaction, error) SaveTransaction(tx *Transaction) error GetTransactionStatus(identity identity.CentID, id uuid.UUID) (*transactionspb.TransactionStatusResponse, error) WaitForTransaction(accountID identity.CentID, txID uuid.UUID) error }
Service wraps the repository and exposes specific functions.
func NewService ¶
func NewService(repo Repository) Service
NewService returns a Service implementation.
type Transaction ¶
type Transaction struct { ID uuid.UUID CID identity.CentID Description string Status Status Logs []Log Metadata map[string]string CreatedAt time.Time }
Transaction contains details of transaction.
func NewTransaction ¶
func NewTransaction(identity identity.CentID, description string) *Transaction
NewTransaction returns a new transaction with a pending state
func (*Transaction) FromJSON ¶
func (t *Transaction) FromJSON(data []byte) error
FromJSON loads the data into transaction.
func (*Transaction) JSON ¶
func (t *Transaction) JSON() ([]byte, error)
JSON returns json marshaled transaction.
func (*Transaction) Type ¶
func (t *Transaction) Type() reflect.Type
Type returns the reflect.Type of the transaction.