Documentation
¶
Index ¶
- Variables
- func AddServices(group string, priority int, async bool, ss ...Service)
- func GetFocusedEvents() []*bind.Element
- func Init(s micro.Service, z Initializer) error
- type Container
- type Dispatcher
- func (d *Dispatcher) AddError(e *eerr.Error)
- func (d *Dispatcher) AddResult(key, value string)
- func (d *Dispatcher) Dispatch(ent *event.Event)
- func (d *Dispatcher) Error(idex int) *eerr.Error
- func (d *Dispatcher) HasError() bool
- func (d *Dispatcher) Result(key string) string
- func (d *Dispatcher) Results() map[string]string
- type EventHandler
- type Initializer
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( // PriorityHigh high PriorityHigh = 0 // PriorityMedium medium PriorityMedium = 10 // PriorityLow low PriorityLow = 20 )
Functions ¶
func AddServices ¶
AddServices add services
Types ¶
type Container ¶
type Container struct {
}
Container service container. Container is an implementation of EventService interface.
func (*Container) OnEvent ¶
func (c *Container) OnEvent(ctx context.Context, req *eproto.EventRequest, rsp *eproto.EventResponse) error
OnEvent entrance of event request
func (*Container) OnRollback ¶
func (c *Container) OnRollback(ctx context.Context, req *eproto.RollbackRequest, rsp *eproto.RollbackResponse) error
OnRollback entrance of rollback request
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher for srv
func NewDispatcher ¶
func NewDispatcher(rsp *eproto.EventResponse) *Dispatcher
NewDispatcher create new dispatcher for srv
func (*Dispatcher) AddResult ¶
func (d *Dispatcher) AddResult(key, value string)
AddResult add result
func (*Dispatcher) Error ¶
func (d *Dispatcher) Error(idex int) *eerr.Error
Error get single error by index
func (*Dispatcher) Result ¶
func (d *Dispatcher) Result(key string) string
Result get result with key
func (*Dispatcher) Results ¶
func (d *Dispatcher) Results() map[string]string
Results get all results
type EventHandler ¶
type EventHandler struct {
ID string // event ID
Name string
Caller reflect.Value
Rollbacker reflect.Value
Priority int
Async bool
}
EventHandler service event handler entry
func GetServiceEvents ¶
func GetServiceEvents(group string, s Service) []*EventHandler
GetServiceEvents get event id list
type Service ¶
type Service interface {
ID() string
}
Service interface. To handle event abc.def.ghi, need method OnDefGhi. To rollback event abc.def.ghi, need method RollbackDefGhi. Event function: func(ctx *engine.Context, e *event.Event) error {} Rollback function: func(e *event.Event, results map[string]string) {}