mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
refactoring
This commit is contained in:
parent
e19d76a5fc
commit
af6a282b6a
3 changed files with 6 additions and 6 deletions
|
@ -70,7 +70,7 @@ func jsonFromFileData(b []byte) ([]subjectAndMessage, error) {
|
||||||
|
|
||||||
for _, m := range MsgSlice {
|
for _, m := range MsgSlice {
|
||||||
s := Subject{
|
s := Subject{
|
||||||
Node: string(m.ToNode),
|
ToNode: string(m.ToNode),
|
||||||
CommandOrEvent: m.CommandOrEvent,
|
CommandOrEvent: m.CommandOrEvent,
|
||||||
Method: m.Method,
|
Method: m.Method,
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -228,7 +228,7 @@ func (s *server) handleMessagesInRingbuffer() {
|
||||||
// by using the goto at the end redo the process for this specific message.
|
// by using the goto at the end redo the process for this specific message.
|
||||||
log.Printf("info: did not find that specific subject, starting new process for subject: %v\n", subjName)
|
log.Printf("info: did not find that specific subject, starting new process for subject: %v\n", subjName)
|
||||||
|
|
||||||
sub := newSubject(sam.Subject.Method, sam.Subject.CommandOrEvent, sam.Subject.Node)
|
sub := newSubject(sam.Subject.Method, sam.Subject.CommandOrEvent, sam.Subject.ToNode)
|
||||||
proc := s.processPrepareNew(sub, s.errorCh, processKindPublisher)
|
proc := s.processPrepareNew(sub, s.errorCh, processKindPublisher)
|
||||||
// fmt.Printf("*** %#v\n", proc)
|
// fmt.Printf("*** %#v\n", proc)
|
||||||
go s.processSpawnWorker(proc)
|
go s.processSpawnWorker(proc)
|
||||||
|
@ -249,7 +249,7 @@ type node string
|
||||||
// specific process
|
// specific process
|
||||||
type Subject struct {
|
type Subject struct {
|
||||||
// node, the name of the node
|
// node, the name of the node
|
||||||
Node string `json:"node" yaml:"node"`
|
ToNode string `json:"node" yaml:"toNode"`
|
||||||
// messageType, command/event
|
// messageType, command/event
|
||||||
CommandOrEvent CommandOrEvent `json:"commandOrEvent" yaml:"commandOrEvent"`
|
CommandOrEvent CommandOrEvent `json:"commandOrEvent" yaml:"commandOrEvent"`
|
||||||
// method, what is this message doing, etc. shellCommand, syslog, etc.
|
// method, what is this message doing, etc. shellCommand, syslog, etc.
|
||||||
|
@ -263,7 +263,7 @@ type Subject struct {
|
||||||
// to receive new messages on the specific subject.
|
// to receive new messages on the specific subject.
|
||||||
func newSubject(method Method, commandOrEvent CommandOrEvent, node string) Subject {
|
func newSubject(method Method, commandOrEvent CommandOrEvent, node string) Subject {
|
||||||
return Subject{
|
return Subject{
|
||||||
Node: node,
|
ToNode: node,
|
||||||
CommandOrEvent: commandOrEvent,
|
CommandOrEvent: commandOrEvent,
|
||||||
Method: method,
|
Method: method,
|
||||||
messageCh: make(chan Message),
|
messageCh: make(chan Message),
|
||||||
|
@ -274,7 +274,7 @@ func newSubject(method Method, commandOrEvent CommandOrEvent, node string) Subje
|
||||||
type subjectName string
|
type subjectName string
|
||||||
|
|
||||||
func (s Subject) name() subjectName {
|
func (s Subject) name() subjectName {
|
||||||
return subjectName(fmt.Sprintf("%s.%s.%s", s.Method, s.CommandOrEvent, s.Node))
|
return subjectName(fmt.Sprintf("%s.%s.%s", s.Method, s.CommandOrEvent, s.ToNode))
|
||||||
}
|
}
|
||||||
|
|
||||||
// processKind are either kindSubscriber or kindPublisher, and are
|
// processKind are either kindSubscriber or kindPublisher, and are
|
||||||
|
@ -313,7 +313,7 @@ func (s *server) processPrepareNew(subject Subject, errCh chan errProcess, proce
|
||||||
proc := process{
|
proc := process{
|
||||||
messageID: 0,
|
messageID: 0,
|
||||||
subject: subject,
|
subject: subject,
|
||||||
node: node(subject.Node),
|
node: node(subject.ToNode),
|
||||||
processID: s.lastProcessID,
|
processID: s.lastProcessID,
|
||||||
errorCh: errCh,
|
errorCh: errCh,
|
||||||
processKind: processKind,
|
processKind: processKind,
|
Loading…
Reference in a new issue