package services
import "github.com/nats-io/nats.go/services"
Index ¶
- Constants
- func SvcControlSubject(verb ServiceVerb, kind, id string) (string, error)
- type Endpoint
- type InternalEndpoint
- type Service
- type ServiceAPIError
- type ServiceConfig
- type ServiceHandler
- type ServiceInfo
- type ServiceSchema
- type ServiceStats
- type ServiceVerb
- type Stats
Constants ¶
const ( // We can fix this, as versions will be on separate subjects and use account mapping to roll requests to new versions etc. QG = "svc" // ServiceApiPrefix is the root of all control subjects ServiceApiPrefix = "$SRV" ServiceErrorHeader = "Nats-Service-Error" )
Functions ¶
func SvcControlSubject ¶
func SvcControlSubject(verb ServiceVerb, kind, id string) (string, error)
SvcControlSubject returns monitoring subjects used by the ServiceImpl
Types ¶
type Endpoint ¶
type Endpoint struct { Subject string `json:"subject"` Handler ServiceHandler }
func (*Endpoint) Valid ¶
type InternalEndpoint ¶
type InternalEndpoint struct { Name string Handler nats.MsgHandler }
type Service ¶
type Service interface { ID() string Name() string Description() string Version() string Stats() ServiceStats Reset() Stop() }
Service is an interface for sevice management. It exposes methods to stop/reset a service, as well as get information on a service.
func Add ¶
func Add(nc *nats.Conn, config ServiceConfig) (Service, error)
Add adds a microservice. NOTE we can do an OpenAPI version as well, but looking at it it was very involved. So I think keep simple version and also have a version that talkes full blown OpenAPI spec and we can pull these things out.
type ServiceAPIError ¶
func (*ServiceAPIError) Error ¶
func (e *ServiceAPIError) Error() string
type ServiceConfig ¶
type ServiceConfig struct { Name string `json:"name"` Description string `json:"description"` Version string `json:"version"` Schema ServiceSchema `json:"schema"` Endpoint Endpoint `json:"endpoint"` StatusHandler func(Endpoint) interface{} }
func (*ServiceConfig) Valid ¶
func (s *ServiceConfig) Valid() error
type ServiceHandler ¶
A request handler. TODO (could make error more and return more info to user automatically?)
type ServiceInfo ¶
type ServiceInfo struct { Name string `json:"name"` ID string `json:"id"` Description string `json:"description"` Version string `json:"version"` Subject string `json:"subject"` }
ServiceInfo is the basic information about a service type
type ServiceSchema ¶
type ServiceStats ¶
type ServiceStats struct { Name string `json:"name"` ID string `json:"id"` Version string `json:"version"` Started time.Time `json:"started"` Endpoints []Stats `json:"stats"` }
Clients can request as well.
type ServiceVerb ¶
type ServiceVerb int64
const ( SrvPing ServiceVerb = iota SrvStatus SrvInfo SrvSchema )
func (ServiceVerb) String ¶
func (s ServiceVerb) String() string
type Stats ¶
type Stats struct { Name string `json:"name"` NumRequests int `json:"num_requests"` NumErrors int `json:"num_errors"` TotalLatency time.Duration `json:"total_latency"` AverageLatency time.Duration `json:"average_latency"` Data interface{} `json:"data"` }
Source Files ¶
- Version
- v1.20.0
- Published
- Nov 11, 2022
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 17 minutes ago –
Tools for package owners.