StatusRestService class

Service that returns microservice status information via HTTP/REST protocol.

The service responds on /status route (can be changed) with a JSON object: { - 'id': unique container id (usually hostname) - 'name': container name (from ContextInfo) - 'description': container description (from ContextInfo) - 'start_time': time when container was started - 'current_time': current time in UTC - 'uptime': duration since container start time in milliseconds - 'properties': additional container properties (from ContextInfo) - 'components': descriptors of components registered in the container }

Configuration parameters

  • base_route: base route for remote URI
  • route: status route (default: 'status')
  • dependencies:
    • endpoint: override for HTTP Endpoint dependency
    • controller: override for Controller dependency
  • connection(s):
    • discovery_key: (optional) a key to retrieve the connection from IDiscovery
    • protocol: connection protocol: http or https
    • host: host name or IP address
    • port: port number
    • uri: resource URI or connection string with all parameters in it

References

  • \*:logger:\*:\*:1.0 (optional) ILogger components to pass log messages
  • \*:counters:\*:\*:1.0 (optional) ICounters components to pass collected measurements
  • \*:discovery:\*:\*:1.0 (optional) IDiscovery services to resolve connection
  • \*:endpoint:http:\*:1.0 (optional) HttpEndpoint reference

See [RestService] See [RestClient]

Example

var service = StatusService();
service.configure(ConfigParams.fromTuples([
    'connection.protocol', 'http',
    'connection.host', 'localhost',
    'connection.port', 8080
]));

await service.open('123')
console.log('The Status service is accessible at http://+:8080/status');
Inheritance

Constructors

StatusRestService()
Creates a new instance of this service.

Properties

baseRoute ↔ String
The base route.
read / write, inherited
counters ↔ CompositeCounters
The performance counters.
read / write, inherited
dependencyResolver ↔ DependencyResolver
The dependency resolver.
read / write, inherited
endpoint HttpEndpoint
The HTTP endpoint that exposes this service.
read / write, inherited
hashCode → int
The hash code for this object. [...]
read-only, inherited
logger ↔ CompositeLogger
The logger.
read / write, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

configure(ConfigParams config) → void
Configures component by passing configuration parameters. [...]
override
register() → void
Registers all service routes in HTTP endpoint.
override
setReferences(IReferences references) → void
Sets references to dependent components. [...]
override
close(String correlationId) → Future
Closes component and frees used resources. [...]
inherited
instrument(String correlationId String name) → Timing
Adds instrumentation to log calls and measure call time. It returns a Timing object that is used to end the time measurement. [...]
inherited
instrumentError(String correlationId, String name, dynamic err, [ bool reerror = false ]) → void
Adds instrumentation to error handling. [...]
inherited
isOpen() → bool
Checks if the component is opened. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
open(String correlationId) → Future
Opens the component. [...]
inherited
registerInterceptor(String route, dynamic action(RequestContext req, ResponseContext res)) → void
Registers a middleware for a given route in HTTP endpoint. [...]
inherited
registerRoute(String method, String route, Schema schema, dynamic action(RequestContext req, ResponseContext res)) → void
Registers a route in HTTP endpoint. [...]
inherited
registerRouteWithAuth(String method, String route, Schema schema, dynamic authorize(RequestContext req, ResponseContext res, dynamic next()), dynamic action(RequestContext req, ResponseContext res)) → void
Registers a route with authorization in HTTP endpoint. [...]
inherited
sendCreatedResult(RequestContext req, ResponseContext res, dynamic err dynamic result) → void
Creates function that sends newly created object as JSON. That function call be called directly or passed as a parameter to business logic components. [...]
inherited
sendDeletedResult(RequestContext req, ResponseContext res, dynamic err dynamic result) → void
Creates a function that sends deleted object as JSON. That function call be called directly or passed as a parameter to business logic components. [...]
inherited
sendError(RequestContext req, ResponseContext res, dynamic error) → void
Sends error serialized as ErrorDescription object and appropriate HTTP status code. If status code is not defined, it uses 500 status code. [...]
inherited
sendResult(RequestContext req, ResponseContext res, dynamic err dynamic result) → void
Sends result as JSON object. That function call be called directly or passed as a parameter to business logic components. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited
unsetReferences() → void
Unsets (clears) previously set references to dependent components.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited