Documentation ¶
Index ¶
- type CanceledByCustomerReason
- type CartValidationErrorReason
- type Context
- type ContextStore
- type ErrorOccurredReason
- type Factory
- type FailedReason
- type FatalRollbackError
- type PaymentCanceledByCustomerReason
- type PaymentErrorOccurredReason
- type PaymentValidatorFunc
- type Process
- func (p *Process) Context() Context
- func (p *Process) CurrentState() (State, error)
- func (p *Process) Failed(ctx context.Context, reason FailedReason)
- func (p *Process) Inject(allStates map[string]State, logger flamingo.Logger, cfg ...) *Process
- func (p *Process) Run(ctx context.Context)
- func (p *Process) UpdateCart(cartToStore cart.Cart)
- func (p *Process) UpdateOrderInfo(info *application.PlaceOrderInfo)
- func (p *Process) UpdateState(s string, stateData StateData)
- type Provider
- type RollbackData
- type RollbackReference
- type RunResult
- type State
- type StateData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CanceledByCustomerReason ¶
type CanceledByCustomerReason struct{}
CanceledByCustomerReason is used when customer cancels order
func (CanceledByCustomerReason) Reason ¶
func (e CanceledByCustomerReason) Reason() string
Reason for the error occurred
type CartValidationErrorReason ¶
type CartValidationErrorReason struct {
ValidationResult validation.Result
}
CartValidationErrorReason contains the ValidationResult
func (CartValidationErrorReason) Reason ¶
func (e CartValidationErrorReason) Reason() string
Reason for failing
type Context ¶
type Context struct { UUID string CurrentStateName string CurrentStateData StateData PlaceOrderInfo *application.PlaceOrderInfo Cart cart.Cart ReturnURL *url.URL RollbackReferences []RollbackReference FailedReason FailedReason }
Context contains information (state etc) about a place order process
type ContextStore ¶
type ContextStore interface { Store(ctx context.Context, key string, placeOrderContext Context) error Get(ctx context.Context, key string) (Context, bool) Delete(ctx context.Context, key string) error }
ContextStore can persist process Context instances
type ErrorOccurredReason ¶
type ErrorOccurredReason struct {
Error string
}
ErrorOccurredReason is used for unspecified errors
func (ErrorOccurredReason) Reason ¶
func (e ErrorOccurredReason) Reason() string
Reason for the error occurred
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory use to get Process instance
func (*Factory) Inject ¶
func (f *Factory) Inject( provider Provider, dep *struct { StartState State `inject:"startState"` FailedState State `inject:"failedState"` }, )
Inject dependencies
type FailedReason ¶
type FailedReason interface {
Reason() string
}
FailedReason gives a human readable reason for a state failure
type FatalRollbackError ¶
type FatalRollbackError struct { State string // contains filtered or unexported fields }
FatalRollbackError which causes the premature end of rollback process
func NewFatalRollbackError ¶
func NewFatalRollbackError(err error, stateName string) FatalRollbackError
NewFatalRollbackError mark a rollback error as fatal, this breaks the current rollback
func (*FatalRollbackError) Error ¶
func (f *FatalRollbackError) Error() string
type PaymentCanceledByCustomerReason ¶
type PaymentCanceledByCustomerReason struct{}
PaymentCanceledByCustomerReason is used to signal that payment was canceled by customer
func (PaymentCanceledByCustomerReason) Reason ¶
func (e PaymentCanceledByCustomerReason) Reason() string
Reason for the error occurred
type PaymentErrorOccurredReason ¶
type PaymentErrorOccurredReason struct {
Error string
}
PaymentErrorOccurredReason is used for errors during payment
func (PaymentErrorOccurredReason) Reason ¶
func (e PaymentErrorOccurredReason) Reason() string
Reason for the error occurred
type PaymentValidatorFunc ¶
type PaymentValidatorFunc func(ctx context.Context, p *Process, paymentService *application.PaymentService) RunResult
PaymentValidatorFunc to decide over next state depending on payment situation
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process representing a place order process and has a current context with infos about result and current state
func (*Process) CurrentState ¶
CurrentState of the process context
func (*Process) Failed ¶
func (p *Process) Failed(ctx context.Context, reason FailedReason)
Failed performs all collected rollbacks and switches to FailedState
func (*Process) Inject ¶
func (p *Process) Inject( allStates map[string]State, logger flamingo.Logger, cfg *struct { Area string `inject:"config:area"` }, ) *Process
Inject dependencies
func (*Process) UpdateCart ¶
UpdateCart updates the cart in the current state context
func (*Process) UpdateOrderInfo ¶
func (p *Process) UpdateOrderInfo(info *application.PlaceOrderInfo)
UpdateOrderInfo updates the order infos of the current context
func (*Process) UpdateState ¶
UpdateState updates the current state in the context and its related state data
type RollbackReference ¶
type RollbackReference struct { StateName string Data RollbackData }
RollbackReference a reference that can be used to trigger a rollback
type RunResult ¶
type RunResult struct { RollbackData RollbackData Failed FailedReason }
RunResult of a state