mirror of
https://github.com/postmannen/ctrl.git
synced 2025-01-18 21:59:30 +00:00
Renamed EchoX to REQPing and REQPong
This commit is contained in:
parent
8f2c4b0db7
commit
1f02cb0d50
5 changed files with 47 additions and 36 deletions
|
@ -106,9 +106,9 @@ type Configuration struct {
|
||||||
// Subscriber for text logging
|
// Subscriber for text logging
|
||||||
StartSubREQTextToLogFile flagNodeSlice
|
StartSubREQTextToLogFile flagNodeSlice
|
||||||
// Subscriber for Echo Request
|
// Subscriber for Echo Request
|
||||||
StartSubEchoRequest flagNodeSlice
|
StartSubREQPing flagNodeSlice
|
||||||
// Subscriber for Echo Reply
|
// Subscriber for Echo Reply
|
||||||
StartSubEchoReply flagNodeSlice
|
StartSubREQPong flagNodeSlice
|
||||||
// Subscriber for CLICommandRequest
|
// Subscriber for CLICommandRequest
|
||||||
StartSubREQCliCommand flagNodeSlice
|
StartSubREQCliCommand flagNodeSlice
|
||||||
// Subscriber for REQnCliCommand
|
// Subscriber for REQnCliCommand
|
||||||
|
@ -137,8 +137,8 @@ func newConfigurationDefaults() Configuration {
|
||||||
StartSubErrorLog: flagNodeSlice{Values: []node{}},
|
StartSubErrorLog: flagNodeSlice{Values: []node{}},
|
||||||
StartSubREQHello: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubREQHello: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
StartSubREQTextToLogFile: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubREQTextToLogFile: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
StartSubEchoRequest: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubREQPing: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
StartSubEchoReply: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubREQPong: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
StartSubREQCliCommand: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubREQCliCommand: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
StartSubREQnCliCommand: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubREQnCliCommand: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
StartSubREQTextToConsole: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubREQTextToConsole: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
|
@ -176,8 +176,8 @@ func (c *Configuration) CheckFlags() error {
|
||||||
flag.Var(&c.StartSubErrorLog, "startSubErrorLog", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubErrorLog, "startSubErrorLog", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
flag.Var(&c.StartSubREQHello, "startSubREQHello", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubREQHello, "startSubREQHello", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
flag.Var(&c.StartSubREQTextToLogFile, "startSubREQTextToLogFile", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubREQTextToLogFile, "startSubREQTextToLogFile", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
flag.Var(&c.StartSubEchoRequest, "startSubEchoRequest", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubREQPing, "startSubREQPing", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
flag.Var(&c.StartSubEchoReply, "startSubEchoReply", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubREQPong, "startSubREQPong", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
flag.Var(&c.StartSubREQCliCommand, "startSubREQCliCommand", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubREQCliCommand, "startSubREQCliCommand", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
flag.Var(&c.StartSubREQnCliCommand, "startSubREQnCliCommand", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubREQnCliCommand, "startSubREQnCliCommand", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
flag.Var(&c.StartSubREQTextToConsole, "startSubREQTextToConsole", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubREQTextToConsole, "startSubREQTextToConsole", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
|
|
|
@ -9,14 +9,6 @@ PromHostAndPort = ":2112"
|
||||||
StartPubREQHello = 0
|
StartPubREQHello = 0
|
||||||
SubscribersDataFolder = "./data"
|
SubscribersDataFolder = "./data"
|
||||||
|
|
||||||
[StartSubEchoReply]
|
|
||||||
OK = true
|
|
||||||
Values = ["*"]
|
|
||||||
|
|
||||||
[StartSubEchoRequest]
|
|
||||||
OK = true
|
|
||||||
Values = ["*"]
|
|
||||||
|
|
||||||
[StartSubErrorLog]
|
[StartSubErrorLog]
|
||||||
OK = true
|
OK = true
|
||||||
Values = ["*"]
|
Values = ["*"]
|
||||||
|
@ -29,6 +21,14 @@ SubscribersDataFolder = "./data"
|
||||||
OK = true
|
OK = true
|
||||||
Values = ["*"]
|
Values = ["*"]
|
||||||
|
|
||||||
|
[StartSubREQPing]
|
||||||
|
OK = true
|
||||||
|
Values = ["*"]
|
||||||
|
|
||||||
|
[StartSubREQPong]
|
||||||
|
OK = true
|
||||||
|
Values = ["*"]
|
||||||
|
|
||||||
[StartSubREQTextToConsole]
|
[StartSubREQTextToConsole]
|
||||||
OK = true
|
OK = true
|
||||||
Values = ["*"]
|
Values = ["*"]
|
||||||
|
|
11
example/toShip1-REQPing.json
Normal file
11
example/toShip1-REQPing.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
|
||||||
|
"toNode": "ship1",
|
||||||
|
"data": [""],
|
||||||
|
"method":"REQPing",
|
||||||
|
"timeout":3,
|
||||||
|
"retries":3,
|
||||||
|
"methodTimeout": 10
|
||||||
|
}
|
||||||
|
]
|
|
@ -75,22 +75,22 @@ func (s *server) ProcessesStart() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start a subscriber for ECHORequest messages
|
// Start a subscriber for Ping Request messages
|
||||||
if s.configuration.StartSubEchoRequest.OK {
|
if s.configuration.StartSubREQPing.OK {
|
||||||
{
|
{
|
||||||
fmt.Printf("Starting Echo Request subscriber: %#v\n", s.nodeName)
|
fmt.Printf("Starting Ping Request subscriber: %#v\n", s.nodeName)
|
||||||
sub := newSubject(ECHORequest, s.nodeName)
|
sub := newSubject(REQPing, s.nodeName)
|
||||||
proc := newProcess(s.processes, s.toRingbufferCh, s.configuration, sub, s.errorKernel.errorCh, processKindSubscriber, s.configuration.StartSubEchoRequest.Values, nil)
|
proc := newProcess(s.processes, s.toRingbufferCh, s.configuration, sub, s.errorKernel.errorCh, processKindSubscriber, s.configuration.StartSubREQPing.Values, nil)
|
||||||
go proc.spawnWorker(s)
|
go proc.spawnWorker(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start a subscriber for ECHOReply messages
|
// Start a subscriber for REQPong messages
|
||||||
if s.configuration.StartSubEchoReply.OK {
|
if s.configuration.StartSubREQPong.OK {
|
||||||
{
|
{
|
||||||
fmt.Printf("Starting Echo Reply subscriber: %#v\n", s.nodeName)
|
fmt.Printf("Starting Pong subscriber: %#v\n", s.nodeName)
|
||||||
sub := newSubject(ECHOReply, s.nodeName)
|
sub := newSubject(REQPong, s.nodeName)
|
||||||
proc := newProcess(s.processes, s.toRingbufferCh, s.configuration, sub, s.errorKernel.errorCh, processKindSubscriber, s.configuration.StartSubEchoReply.Values, nil)
|
proc := newProcess(s.processes, s.toRingbufferCh, s.configuration, sub, s.errorKernel.errorCh, processKindSubscriber, s.configuration.StartSubREQPong.Values, nil)
|
||||||
go proc.spawnWorker(s)
|
go proc.spawnWorker(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,9 +91,9 @@ const (
|
||||||
// Echo request will ask the subscriber for a
|
// Echo request will ask the subscriber for a
|
||||||
// reply generated as a new message, and sent back to where
|
// reply generated as a new message, and sent back to where
|
||||||
// the initial request was made.
|
// the initial request was made.
|
||||||
ECHORequest Method = "ECHORequest"
|
REQPing Method = "REQPing"
|
||||||
// Will generate a reply for a ECHORequest
|
// Will generate a reply for a ECHORequest
|
||||||
ECHOReply Method = "ECHOReply"
|
REQPong Method = "REQPong"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The mapping of all the method constants specified, what type
|
// The mapping of all the method constants specified, what type
|
||||||
|
@ -131,10 +131,10 @@ func (m Method) GetMethodsAvailable() MethodsAvailable {
|
||||||
ErrorLog: methodErrorLog{
|
ErrorLog: methodErrorLog{
|
||||||
commandOrEvent: EventACK,
|
commandOrEvent: EventACK,
|
||||||
},
|
},
|
||||||
ECHORequest: methodEchoRequest{
|
REQPing: methodREQPing{
|
||||||
commandOrEvent: EventACK,
|
commandOrEvent: EventACK,
|
||||||
},
|
},
|
||||||
ECHOReply: methodEchoReply{
|
REQPong: methodREQPong{
|
||||||
commandOrEvent: EventACK,
|
commandOrEvent: EventACK,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -356,20 +356,20 @@ func (m methodErrorLog) handler(proc process, message Message, node string) ([]b
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
type methodEchoRequest struct {
|
type methodREQPing struct {
|
||||||
commandOrEvent CommandOrEvent
|
commandOrEvent CommandOrEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m methodEchoRequest) getKind() CommandOrEvent {
|
func (m methodREQPing) getKind() CommandOrEvent {
|
||||||
return m.commandOrEvent
|
return m.commandOrEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m methodEchoRequest) handler(proc process, message Message, node string) ([]byte, error) {
|
func (m methodREQPing) handler(proc process, message Message, node string) ([]byte, error) {
|
||||||
log.Printf("<--- ECHO REQUEST received from: %v, containing: %v", message.FromNode, message.Data)
|
log.Printf("<--- PING REQUEST received from: %v, containing: %v", message.FromNode, message.Data)
|
||||||
|
|
||||||
// Prepare and queue for sending a new message with the output
|
// Prepare and queue for sending a new message with the output
|
||||||
// of the action executed.
|
// of the action executed.
|
||||||
newReplyMessage(proc, message, ECHOReply, []byte{})
|
newReplyMessage(proc, message, REQPong, []byte{})
|
||||||
|
|
||||||
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
||||||
return ackMsg, nil
|
return ackMsg, nil
|
||||||
|
@ -377,15 +377,15 @@ func (m methodEchoRequest) handler(proc process, message Message, node string) (
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
type methodEchoReply struct {
|
type methodREQPong struct {
|
||||||
commandOrEvent CommandOrEvent
|
commandOrEvent CommandOrEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m methodEchoReply) getKind() CommandOrEvent {
|
func (m methodREQPong) getKind() CommandOrEvent {
|
||||||
return m.commandOrEvent
|
return m.commandOrEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m methodEchoReply) handler(proc process, message Message, node string) ([]byte, error) {
|
func (m methodREQPong) handler(proc process, message Message, node string) ([]byte, error) {
|
||||||
log.Printf("<--- ECHO Reply received from: %v, containing: %v", message.FromNode, message.Data)
|
log.Printf("<--- ECHO Reply received from: %v, containing: %v", message.FromNode, message.Data)
|
||||||
|
|
||||||
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
||||||
|
|
Loading…
Add table
Reference in a new issue