ControlSubject returns monitoring subjects used by the Service. Providing a verb is mandatory (it should be one of Ping, Info or Stats). Depending on whether kind and id are provided, ControlSubject will return one of the following: - verb only: subject used to monitor all available services - verb
(verb Verb, name, id string)
| 935 | // - verb and kind: subject used to monitor services with the provided name |
| 936 | // - verb, name and id: subject used to monitor an instance of a service with the provided ID |
| 937 | func ControlSubject(verb Verb, name, id string) (string, error) { |
| 938 | verbStr := verb.String() |
| 939 | if verbStr == "" { |
| 940 | return "", fmt.Errorf("%w: %q", ErrVerbNotSupported, verbStr) |
| 941 | } |
| 942 | if name == "" && id != "" { |
| 943 | return "", ErrServiceNameRequired |
| 944 | } |
| 945 | if name == "" && id == "" { |
| 946 | return fmt.Sprintf("%s.%s", APIPrefix, verbStr), nil |
| 947 | } |
| 948 | if id == "" { |
| 949 | return fmt.Sprintf("%s.%s.%s", APIPrefix, verbStr, name), nil |
| 950 | } |
| 951 | return fmt.Sprintf("%s.%s.%s.%s", APIPrefix, verbStr, name, id), nil |
| 952 | } |
| 953 | |
| 954 | func WithEndpointSubject(subject string) EndpointOpt { |
| 955 | return func(e *endpointOpts) error { |