Пример #1
0
func (order *Order) ForceStatePosition(stateMachine *state.StateMachine, targetState string, position *Position) error {
	if stateMachine == nil {
		stateMachine = DefaultStateMachine
	}
	err := stateMachine.ForceTransitionToState(position.GetState(), targetState)
	if err != nil {
		return err
	}
	return order.Upsert()
}
Пример #2
0
// SetState performs the transition to target state
// If stateMachine is nil, the default state machine is used
func (order *Order) SetState(stateMachine *state.StateMachine, targetState string) error {
	if stateMachine == nil {
		stateMachine = DefaultStateMachine
	}
	err := stateMachine.TransitionToState(order.GetState(), targetState)
	if err != nil {
		return err
	}
	return order.Upsert()
}
Пример #3
0
func (order *Order) SetInitialState(stateMachine *state.StateMachine) {
	order.State = stateMachine.GetInitialState()
}
Пример #4
0
func (position *Position) SetInitialState(stateMachine *state.StateMachine) {
	position.State = stateMachine.GetInitialState()
}