mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
updated comments with references to command to just have for the event type
This commit is contained in:
parent
49aa0fae20
commit
4390d494f4
5 changed files with 11 additions and 17 deletions
|
@ -7,14 +7,12 @@
|
|||
package steward
|
||||
|
||||
// Event describes on the message level if this is
|
||||
// an event or command kind of message in the Subject name.
|
||||
// an ACK or NACK kind of message in the Subject name.
|
||||
// This field is mainly used to be able to spawn up different
|
||||
// worker processes based on the Subject name so we can have
|
||||
// one process for handling event kind, and another for
|
||||
// handling command kind of messages.
|
||||
// worker processes based on the Subject name.
|
||||
// This type is used in both building the subject name, and
|
||||
// also inside the Message type to describe if it is a Command
|
||||
// or Event.
|
||||
// also inside the Message type to describe what kind like
|
||||
// ACK or NACK it is.
|
||||
type Event string
|
||||
|
||||
func (c Event) CheckEventAvailable() EventAvailable {
|
||||
|
@ -46,14 +44,14 @@ type EventAvailable struct {
|
|||
topics map[Event]struct{}
|
||||
}
|
||||
|
||||
// Check if a command or even exists.
|
||||
// Check if an event exists.
|
||||
func (e EventAvailable) CheckIfExists(event Event, subject Subject) bool {
|
||||
_, ok := e.topics[event]
|
||||
if ok {
|
||||
// log.Printf("info: EventAvailable.CheckIfExists: command or event found: %v, for %v\n", c, subject.name())
|
||||
// log.Printf("info: EventAvailable.CheckIfExists: event found: %v, for %v\n", c, subject.name())
|
||||
return true
|
||||
} else {
|
||||
// log.Printf("error: EventAvailable.CheckIfExists: command or event not found: %v, for %v\n", c, subject.name())
|
||||
// log.Printf("error: EventAvailable.CheckIfExists: event not found: %v, for %v\n", c, subject.name())
|
||||
return false
|
||||
}
|
||||
}
|
|
@ -103,7 +103,7 @@ type Node string
|
|||
type Subject struct {
|
||||
// node, the name of the node to receive the message.
|
||||
ToNode string `json:"node" yaml:"toNode"`
|
||||
// messageType, command/event
|
||||
// Event, event type like EventACK or EventNACK.
|
||||
Event Event `json:"event" yaml:"event"`
|
||||
// method, what is this message doing, etc. CLICommand, Syslog, etc.
|
||||
Method Method `json:"method" yaml:"method"`
|
||||
|
|
|
@ -536,7 +536,7 @@ func (p process) messageSubscriberHandler(natsConn *nats.Conn, thisNode string,
|
|||
}
|
||||
|
||||
default:
|
||||
er := fmt.Errorf("info: did not find that specific type of command or event: %#v", p.subject.Event)
|
||||
er := fmt.Errorf("info: did not find that specific type of event: %#v", p.subject.Event)
|
||||
p.processes.errorKernel.infoSend(p, message, er)
|
||||
|
||||
}
|
||||
|
|
|
@ -133,15 +133,11 @@ const (
|
|||
// The mapping of all the method constants specified, what type
|
||||
// it references, and the kind if it is an Event or Command, and
|
||||
// if it is ACK or NACK.
|
||||
// Allowed values for the commandOrEvent field are:
|
||||
// - CommandACK
|
||||
// - CommandNACK
|
||||
// Allowed values for the Event field are:
|
||||
// - EventACK
|
||||
// - EventNack
|
||||
func (m Method) GetMethodsAvailable() MethodsAvailable {
|
||||
|
||||
// Command, Used to make a request to perform an action
|
||||
// Event, Used to communicate that something have happened.
|
||||
ma := MethodsAvailable{
|
||||
Methodhandlers: map[Method]methodHandler{
|
||||
REQInitial: methodREQInitial{
|
||||
|
|
|
@ -409,7 +409,7 @@ func (s *server) routeMessagesToProcess(dbFileName string) {
|
|||
continue
|
||||
}
|
||||
if !eventAvailable.CheckIfExists(sam.Subject.Event, sam.Subject) {
|
||||
er := fmt.Errorf("error: routeMessagesToProcess: the command or event do not exist, message dropped: %v", sam.Message.Method)
|
||||
er := fmt.Errorf("error: routeMessagesToProcess: the event type do not exist, message dropped: %v", sam.Message.Method)
|
||||
s.errorKernel.errSend(s.processInitial, sam.Message, er)
|
||||
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue