Documentation
¶
Overview ¶
Package node provides interface for creation and publishing node using Erlang distribution protocol: http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html
The Publish function allows incoming connection to the current node on 5858 port. EPMD will reply with this port on name request for this node name
enode := node.NewNode(name, cookie)
err := enode.Publish(5858)
if err != nil {
log.Printf("Cannot publish: %s", err)
enode = nil
}
Function Spawn creates new process from struct which implements Process interface:
eSrv := new(eclusSrv) pid := enode.Spawn(eSrv)
Now you can call Register function to store this pid with arbitrary name:
enode.Register(etf.Atom("eclus"), pid)
Index ¶
- Constants
- type Behaviour
- type GenServer
- type GenServerImpl
- type Node
- func (n *Node) Publish(port int) (err error)
- func (currNode *Node) RegSend(from, to etf.Term, message etf.Term)
- func (n *Node) Register(name etf.Atom, pid etf.Pid)
- func (n *Node) Registered() (pids []etf.Atom)
- func (currNode *Node) RpcProvide(modName string, funName string, fun rpcFunction) (err error)
- func (currNode *Node) RpcRevoke(modName, funName string)
- func (currNode *Node) Send(to etf.Pid, message etf.Term)
- func (currNode *Node) SendFrom(from etf.Term, to etf.Pid, message etf.Term)
- func (n *Node) Spawn(pd Process, args ...interface{}) (pid etf.Pid)
- func (n *Node) Unregister(name etf.Atom)
- func (currNode *Node) Whereis(who etf.Atom) (pid etf.Pid)
- type Process
Constants ¶
const ( LINK = 1 SEND = 2 EXIT = 3 UNLINK = 4 NODE_LINK = 5 REG_SEND = 6 GROUP_LEADER = 7 EXIT2 = 8 SEND_TT = 12 EXIT_TT = 13 REG_SEND_TT = 16 EXIT2_TT = 18 MONITOR_P = 19 DEMONITOR_P = 20 MONITOR_P_EXIT = 21 )
Distributed operations codes (http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Behaviour ¶
type Behaviour interface {
ProcessLoop(pcs procChannels, pd Process, args ...interface{}) // method which implements control flow of process
}
Behaviour interface contains methods you should implement to make own process behaviour
type GenServer ¶
type GenServer interface {
Init(args ...interface{})
HandleCast(message *etf.Term)
HandleCall(message *etf.Term, from *etf.Tuple) (reply *etf.Term)
HandleInfo(message *etf.Term)
Terminate(reason interface{})
}
GenServer interface
type GenServerImpl ¶
GenServerImpl is implementation of GenServer interface
func (*GenServerImpl) Options ¶
func (gs *GenServerImpl) Options() map[string]interface{}
Options returns map of default process-related options
func (*GenServerImpl) ProcessLoop ¶
func (gs *GenServerImpl) ProcessLoop(pcs procChannels, pd Process, args ...interface{})
ProcessLoop executes during whole time of process life. It receives incoming messages from channels and handle it using methods of behaviour implementation
type Node ¶
func (*Node) Publish ¶
Publish allow node be visible to other Erlang nodes via publishing port in EPMD
func (*Node) Registered ¶
Registered returns a list of names which have been registered using Register
func (*Node) RpcProvide ¶
func (*Node) Unregister ¶
Unregister removes the registered name