From 88532f4a6eb25f80a34ce556c267c9ef5ddced3f Mon Sep 17 00:00:00 2001 From: postmannen Date: Wed, 19 Apr 2023 05:46:38 +0200 Subject: [PATCH] updated readme with toNode local --- README.md | 27 +++++++++++++++++++++++++-- processes.go | 9 ++------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3b38d3c..c0066c1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/processes.go b/processes.go index 48e4e72..29b6de3 100644 --- a/processes.go +++ b/processes.go @@ -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)