srv

package
v0.0.0-...-38decf1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// PriorityHigh high
	PriorityHigh = 0

	// PriorityMedium medium
	PriorityMedium = 10

	// PriorityLow low
	PriorityLow = 20
)

Functions

func AddServices

func AddServices(group string, priority int, async bool, ss ...Service)

AddServices add services

func GetFocusedEvents

func GetFocusedEvents() []*bind.Element

GetFocusedEvents get focused events

func Init

func Init(s micro.Service, z Initializer) error

Init srv

Types

type Container

type Container struct {
}

Container service container. Container is an implementation of EventService interface.

func NewContainer

func NewContainer() *Container

NewContainer create new container

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

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) AddError

func (d *Dispatcher) AddError(e *eerr.Error)

AddError add error

func (*Dispatcher) AddResult

func (d *Dispatcher) AddResult(key, value string)

AddResult add result

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(ent *event.Event)

Dispatch event

func (*Dispatcher) Error

func (d *Dispatcher) Error(idex int) *eerr.Error

Error get single error by index

func (*Dispatcher) HasError

func (d *Dispatcher) HasError() bool

HasError check if got an error

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 Initializer

type Initializer interface {
	InitServices()
}

Initializer of srv

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) {}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址