Documentation ¶
Index ¶
- func InitLogger(gl *logrus.Logger)
- type Callback
- type Event
- type Graph
- type Node
- type NodeDelegate
- func (nd *NodeDelegate) Deliver(linkId int, evt *Event) bool
- func (nd *NodeDelegate) DeliverSelf(evt *Event) bool
- func (nd *NodeDelegate) DeliverWithTimeout(linkId int, evt *Event, timeout time.Duration) bool
- func (nd *NodeDelegate) RequestLinkDown(linkId int) (err error)
- func (nd *NodeDelegate) RequestLinkUp(scope string, nodeName string) (linkId int)
- func (nd *NodeDelegate) RequestNodeExit() (err error)
- type NodeProperty
- func (np *NodeProperty) GetDataChannelSize() int
- func (np *NodeProperty) GetDeliveryTimeout() time.Duration
- func (np *NodeProperty) GetMaxLink() int
- func (np *NodeProperty) SetDataChannelSize(size int)
- func (np *NodeProperty) SetDeliveryTimeout(d time.Duration)
- func (np *NodeProperty) SetMaxLink(m int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLogger ¶ added in v0.0.2
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
func NewEventWithCallback ¶ added in v0.0.2
type Graph ¶ added in v0.0.2
type Graph struct {
// contains filtered or unexported fields
}
func NewEventGraph ¶
func NewEventGraph() *Graph
type Node ¶
type Node interface { GetNodeName() string GetNodeScope() string // normal event handling OnEvent(evt *Event) // dlink status change OnLinkDown(linkId int, scope string, nodeName string) // after sucessfully added to graph OnEnter(delegate *NodeDelegate) // the finalizing method after node exits graph OnExit() }
type NodeDelegate ¶
type NodeDelegate struct {
// contains filtered or unexported fields
}
NodeDelegate is delegated to interact with event graph directly it is the only way for Node to send events by NodeDelegate
func (*NodeDelegate) Deliver ¶ added in v0.0.2
func (nd *NodeDelegate) Deliver(linkId int, evt *Event) bool
func (*NodeDelegate) DeliverSelf ¶ added in v0.0.2
func (nd *NodeDelegate) DeliverSelf(evt *Event) bool
DeliverSelf [SYNC] directly puts event to this node's event loop it is a convenient way to talk to the node, and node can choose to expose api to let caller who has a reference to this node directly sending message to node from the node's perspective, it doesn't care about the source of every event
func (*NodeDelegate) DeliverWithTimeout ¶ added in v0.0.2
DeliverWithTimeout [SYNC] return true if successfully delivered
func (*NodeDelegate) RequestLinkDown ¶
func (nd *NodeDelegate) RequestLinkDown(linkId int) (err error)
RequestLinkDown [ASYNC] node request tearing down an output dlink, and node's OnLinkDown would be invoked once successfully tearing down
func (*NodeDelegate) RequestLinkUp ¶
func (nd *NodeDelegate) RequestLinkUp(scope string, nodeName string) (linkId int)
RequestLinkUp [SYNC] node request dlink to other node of @param scope and name @param nodeName the request is passed to graph, then graph would create the dlink and notify the node delegate. if the requested node doesn't exist or any error happened, linkId == -1
func (*NodeDelegate) RequestNodeExit ¶
func (nd *NodeDelegate) RequestNodeExit() (err error)
RequestNodeExit [ASYNC] ask graph to remove this node, and OnExit would be invoked
type NodeProperty ¶ added in v0.0.2
type NodeProperty struct {
// contains filtered or unexported fields
}
NodeProperty embed it if node needs to be customized ----------------------------------------------------------- maxLink int:
override default max output link number
dataChannelSize int:
override default buffered event channel size
deliveryTimeout time.Duration:
override default event delivery timeout
func (*NodeProperty) GetDataChannelSize ¶ added in v0.0.2
func (np *NodeProperty) GetDataChannelSize() int
func (*NodeProperty) GetDeliveryTimeout ¶ added in v0.0.2
func (np *NodeProperty) GetDeliveryTimeout() time.Duration
func (*NodeProperty) GetMaxLink ¶ added in v0.0.2
func (np *NodeProperty) GetMaxLink() int
func (*NodeProperty) SetDataChannelSize ¶ added in v0.0.2
func (np *NodeProperty) SetDataChannelSize(size int)
func (*NodeProperty) SetDeliveryTimeout ¶ added in v0.0.2
func (np *NodeProperty) SetDeliveryTimeout(d time.Duration)
func (*NodeProperty) SetMaxLink ¶ added in v0.0.2
func (np *NodeProperty) SetMaxLink(m int)