...
Code Block |
---|
cloudhub.Register(c.Modules.CloudHub) edgecontroller.Register(c.Modules.EdgeController) devicecontroller.Register(c.Modules.DeviceController) nodeupgradejobcontroller.Register(c.Modules.NodeUpgradeJobController) synccontroller.Register(c.Modules.SyncController) cloudstream.Register(c.Modules.CloudStream, c.CommonConfig) router.Register(c.Modules.Router) dynamiccontroller.Register(c.Modules.DynamicController) |
Beehive
...
uses
...
the
...
golang
...
channel
...
to
...
realize
...
inter-module
...
communication.
...
The
...
communication
...
methods
...
include
...
"unicast"
...
and
...
"multicast",
...
that
...
is,
...
the
...
message
...
can
...
be
...
sent
...
to
...
a
...
certain
...
module
...
alone,
...
or
...
the
...
message
...
can
...
be
...
sent
...
to
...
the
...
module
...
group
...
(that
...
is,
...
the
...
edged,
...
hub,
...
bus
...
and
...
other
...
groups
...
mentioned
...
above).
...
Beehive
...
uses
...
context
...
to
...
manage
...
communication
...
between
...
groups
...
and
...
modules.
...
When
...
using
...
channel
...
as
...
the
...
communication
...
method,
...
ChannelContext
...
implements two interfaces related to context: ModuleContext and MessageContext.
Code Block |
---|
// ModuleContext is interface for context module management
type ModuleContext interface {
AddModule(info *common.ModuleInfo)
AddModuleGroup(module, group string)
Cleanup(module string)
} |
Code Block |
---|
// MessageContext is interface for message syncing
type MessageContext interface {
// async mode
Send(module string, message model.Message)
Receive(module string) (model.Message, error)
// sync mode
SendSync(module string, message model.Message, timeout time.Duration) (model.Message, error)
SendResp(message model.Message)
// group broadcast
SendToGroup(group string, message model.Message)
SendToGroupSync(group string, message model.Message, timeout time.Duration) error
} |