1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

updated readme with toNode local

This commit is contained in:
postmannen 2023-04-19 05:46:38 +02:00
parent 7b4335a256
commit 88532f4a6e
2 changed files with 27 additions and 9 deletions

View file

@ -40,6 +40,7 @@ As long as you can do something as an operator on in a shell on a system you can
- [startup folder](#startup-folder)
- [General functionality](#general-functionality)
- [How to send the reply to another node](#how-to-send-the-reply-to-another-node)
- [Use local as the toNode nodename](#use-local-as-the-tonode-nodename)
- [method timeout](#method-timeout)
- [Example](#example)
- [Schedule a Method in a message to be run several times](#schedule-a-method-in-a-message-to-be-run-several-times)
@ -433,9 +434,31 @@ Messages put in the startup folder will not be sent to the broker but handled lo
#### How to send the reply to another node
Normally the **fromNode** field is automatically filled in with the node name of the node where a message originated.
Normally the **fromNode** field is automatically filled in with the node name of the node where a message originated. Since messages within the startup folder is not received from another node via the normal message path we need to specify the **fromNode** field within the message for where we want the reply delivered.
Since messages within the startup folder is not received from another node via the normal message path we need to specify the **fromNode** field within the message for where we want the reply delivered.
As an example. If You want to place a message on the startup folder of **node1** and send the result to **node2**. Specify **node2** as the **fromNode**, and **node1** as the **toNode**
#### Use local as the toNode nodename
Since messages used in startup folder are ment to be delivered locally we can simply things a bit by setting the **toNode** field value of the message to **local**.
```json
[
{
"toNode": "local",
"fromNode": "central",
"method": "REQCliCommand",
"methodArgs": [
"bash",
"-c",
"curl localhost:2111/metrics"
],
"replyMethod": "REQToConsole",
"methodTimeout": 10
}
]
```
#### method timeout

View file

@ -329,9 +329,7 @@ func (p *processes) Start(proc process) {
proc.startup.subscriber(proc, REQKeysRequestUpdate, nil)
proc.startup.subscriber(proc, REQKeysAllow, nil)
proc.startup.subscriber(proc, REQKeysDelete, nil)
proc.startup.subscriber(proc, REQAclRequestUpdate, nil)
proc.startup.subscriber(proc, REQAclAddCommand, nil)
proc.startup.subscriber(proc, REQAclDeleteCommand, nil)
proc.startup.subscriber(proc, REQAclDeleteSource, nil)
@ -345,11 +343,6 @@ func (p *processes) Start(proc process) {
proc.startup.subscriber(proc, REQAclImport, nil)
}
// Moved this together with proc.configuration.StartPubREQKeysRequestUpdate since they belong together.
// if proc.configuration.StartSubREQKeysDeliverUpdate {
// proc.startup.subREQKeysDeliverUpdate(proc)
// }
if proc.configuration.StartSubREQHttpGet {
proc.startup.subscriber(proc, REQHttpGet, nil)
}
@ -397,6 +390,8 @@ func newStartup(server *server) *startup {
return &s
}
// subscriber will start a subscriber process. It takes the initial process, request method,
// and a procFunc as it's input arguments. If a procFunc os not needed, use the value nil.
func (s *startup) subscriber(p process, m Method, pf func(ctx context.Context, procFuncCh chan Message) error) {
er := fmt.Errorf("starting %v subscriber: %#v", m, p.node)
p.errorKernel.logDebug(er, p.configuration)