2023-08-10 15:49:25 +03:00
|
|
|
package tx
|
2023-07-09 01:28:59 +03:00
|
|
|
|
2023-08-16 17:25:56 +03:00
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
)
|
2023-08-12 15:54:05 +03:00
|
|
|
|
2023-08-16 17:25:56 +03:00
|
|
|
// Jsonable Action.
|
|
|
|
type action struct {
|
|
|
|
Type string
|
|
|
|
Action Action
|
|
|
|
}
|
|
|
|
|
|
|
|
func newAction(a Action) *action {
|
|
|
|
typ, ok := actionMapByReflect[reflect.TypeOf(a)]
|
|
|
|
if !ok {
|
|
|
|
panic(ActionNotDefinedErr)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &action{
|
|
|
|
Type: typ,
|
|
|
|
Action: a,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-18 13:46:10 +03:00
|
|
|
func (a *action) Act(c *Context) {
|
2023-08-16 17:25:56 +03:00
|
|
|
if a.Action != nil {
|
2023-08-18 13:46:10 +03:00
|
|
|
a.Action.Act(c)
|
2023-08-16 17:25:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-13 15:37:36 +03:00
|
|
|
// The argument for handling in channenl behaviours.
|
2023-08-18 13:46:10 +03:00
|
|
|
type ChannelContext struct {
|
2023-08-13 15:37:36 +03:00
|
|
|
}
|
2023-08-18 13:46:10 +03:00
|
|
|
type CC = ChannelContext
|
2023-08-13 15:37:36 +03:00
|
|
|
type ChannelAction struct {
|
2023-08-18 13:46:10 +03:00
|
|
|
Act (*ChannelContext)
|
2023-08-12 19:06:23 +03:00
|
|
|
}
|