addVerbHandlers generates control handlers for a specific verb. Each request generates 3 subscriptions, one for the general verb affecting all services written with the framework, one that handles all services of a particular kind, and finally a specific service instance.
(nc *nats.Conn, verb Verb, handler HandlerFunc)
| 654 | // affecting all services written with the framework, one that handles |
| 655 | // all services of a particular kind, and finally a specific service instance. |
| 656 | func (svc *service) addVerbHandlers(nc *nats.Conn, verb Verb, handler HandlerFunc) error { |
| 657 | name := fmt.Sprintf("%s-all", verb.String()) |
| 658 | if err := svc.addInternalHandler(nc, verb, "", "", name, handler); err != nil { |
| 659 | return err |
| 660 | } |
| 661 | name = fmt.Sprintf("%s-kind", verb.String()) |
| 662 | if err := svc.addInternalHandler(nc, verb, svc.Config.Name, "", name, handler); err != nil { |
| 663 | return err |
| 664 | } |
| 665 | return svc.addInternalHandler(nc, verb, svc.Config.Name, svc.id, verb.String(), handler) |
| 666 | } |
| 667 | |
| 668 | // addInternalHandler registers a control subject handler. |
| 669 | func (s *service) addInternalHandler(nc *nats.Conn, verb Verb, kind, id, name string, handler HandlerFunc) error { |
no test coverage detected