mirror of
https://github.com/postmannen/ctrl.git
synced 2025-01-05 20:09:16 +00:00
split out start pub/sub process in separate func's
This commit is contained in:
parent
d0d3ef8b39
commit
215a4c387a
1 changed files with 63 additions and 56 deletions
31
process.go
31
process.go
|
@ -187,7 +187,25 @@ func (p process) spawnWorker() {
|
|||
// Start a publisher worker, which will start a go routine (process)
|
||||
// That will take care of all the messages for the subject it owns.
|
||||
if p.processKind == processKindPublisher {
|
||||
p.startPublisher()
|
||||
}
|
||||
|
||||
// Start a subscriber worker, which will start a go routine (process)
|
||||
// That will take care of all the messages for the subject it owns.
|
||||
if p.processKind == processKindSubscriber {
|
||||
p.startSubscriber()
|
||||
}
|
||||
|
||||
// Add information about the new process to the started processes map.
|
||||
p.processes.active.mu.Lock()
|
||||
p.processes.active.procNames[p.processName] = p
|
||||
p.processes.active.mu.Unlock()
|
||||
|
||||
er := fmt.Errorf("successfully started process: %v", p.processName)
|
||||
p.errorKernel.logConsoleOnlyIfDebug(er, p.configuration)
|
||||
}
|
||||
|
||||
func (p process) startPublisher() {
|
||||
// If there is a procFunc for the process, start it.
|
||||
if p.procFunc != nil {
|
||||
// Initialize the channel for communication between the proc and
|
||||
|
@ -208,9 +226,7 @@ func (p process) spawnWorker() {
|
|||
go p.publishMessages(p.natsConn)
|
||||
}
|
||||
|
||||
// Start a subscriber worker, which will start a go routine (process)
|
||||
// That will take care of all the messages for the subject it owns.
|
||||
if p.processKind == processKindSubscriber {
|
||||
func (p process) startSubscriber() {
|
||||
// If there is a procFunc for the process, start it.
|
||||
if p.procFunc != nil {
|
||||
// Initialize the channel for communication between the proc and
|
||||
|
@ -250,15 +266,6 @@ func (p process) spawnWorker() {
|
|||
}()
|
||||
}
|
||||
|
||||
// Add information about the new process to the started processes map.
|
||||
p.processes.active.mu.Lock()
|
||||
p.processes.active.procNames[p.processName] = p
|
||||
p.processes.active.mu.Unlock()
|
||||
|
||||
er := fmt.Errorf("successfully started process: %v", p.processName)
|
||||
p.errorKernel.logConsoleOnlyIfDebug(er, p.configuration)
|
||||
}
|
||||
|
||||
var (
|
||||
ErrACKSubscribeRetry = errors.New("steward: retrying to subscribe for ack message")
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue