mirror of
https://github.com/postmannen/ctrl.git
synced 2025-03-05 14:56:49 +00:00
Added REQPublicKey
This commit is contained in:
parent
afe24716db
commit
f5f0c11dd6
2 changed files with 36 additions and 1 deletions
10
processes.go
10
processes.go
|
@ -191,6 +191,8 @@ func (p *processes) Start(proc process) {
|
||||||
proc.startup.subREQRelayInitial(proc)
|
proc.startup.subREQRelayInitial(proc)
|
||||||
|
|
||||||
proc.startup.subREQToSocket(proc)
|
proc.startup.subREQToSocket(proc)
|
||||||
|
|
||||||
|
proc.startup.subREQPublicKey(proc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop all subscriber processes.
|
// Stop all subscriber processes.
|
||||||
|
@ -431,6 +433,14 @@ func (s startup) subREQToSocket(p process) {
|
||||||
go proc.spawnWorker(p.processes, p.natsConn)
|
go proc.spawnWorker(p.processes, p.natsConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s startup) subREQPublicKey(p process) {
|
||||||
|
log.Printf("Starting get Public Key subscriber: %#v\n", p.node)
|
||||||
|
sub := newSubject(REQPublicKey, string(p.node))
|
||||||
|
proc := newProcess(p.ctx, s.metrics, p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, processKindSubscriber, nil, p.signatures)
|
||||||
|
|
||||||
|
go proc.spawnWorker(p.processes, p.natsConn)
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
// Print the content of the processes map.
|
// Print the content of the processes map.
|
||||||
|
|
27
requests.go
27
requests.go
|
@ -129,7 +129,7 @@ const (
|
||||||
// REQNone is used when there should be no reply.
|
// REQNone is used when there should be no reply.
|
||||||
REQNone Method = "REQNone"
|
REQNone Method = "REQNone"
|
||||||
// REQPublicKey will get the public ed25519 certificate from a node.
|
// REQPublicKey will get the public ed25519 certificate from a node.
|
||||||
REQPublicKey
|
REQPublicKey Method = "REQPublicKey"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The mapping of all the method constants specified, what type
|
// The mapping of all the method constants specified, what type
|
||||||
|
@ -1837,6 +1837,31 @@ func (m methodREQPublicKey) getKind() Event {
|
||||||
|
|
||||||
// Handler to get the public ed25519 key from a node.
|
// Handler to get the public ed25519 key from a node.
|
||||||
func (m methodREQPublicKey) handler(proc process, message Message, node string) ([]byte, error) {
|
func (m methodREQPublicKey) handler(proc process, message Message, node string) ([]byte, error) {
|
||||||
|
// Get a context with the timeout specified in message.MethodTimeout.
|
||||||
|
ctx, _ := getContextForMethodTimeout(proc.ctx, message)
|
||||||
|
|
||||||
|
proc.processes.wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer proc.processes.wg.Done()
|
||||||
|
outCh := make(chan []byte)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
case outCh <- proc.signatures.SignPublicKey:
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
// case proc.toRingbufferCh <- []subjectAndMessage{sam}:
|
||||||
|
case <-ctx.Done():
|
||||||
|
case out := <-outCh:
|
||||||
|
|
||||||
|
// Prepare and queue for sending a new message with the output
|
||||||
|
// of the action executed.
|
||||||
|
newReplyMessage(proc, message, out)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// Send back an ACK message.
|
// Send back an ACK message.
|
||||||
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