HeartbeatRestController

This controllers returns heartbeat via HTTP/REST protocol.

Extends: RestController

Description

The HeartbeatRestController class allows you to create controllers that return heartbeat via HTTP/REST protocol.

Important points

  • The controller responds on /heartbeat route (can be changed) with a string with the current time in UTC.
  • This controller route can be used to perform health checks by loadbalancers and container orchestrators.

Configuration parameters

  • base_route: base route for remote URI (default: “")
  • route: route to heartbeat operation (default: “heartbeat”)
  • dependencies:
    • endpoint: override for HTTP Endpoint dependency
  • connection(s):
    • discovery_key: (optional) 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
  • *:traces:*:*:1.0 - (optional) ITracer components to record traces
  • *:discovery:*:*:1.0 - (optional) IDiscovery controllers to resolve connection

Constructors

Creates a new instance of this controller.

HeartbeatRestController()

Instance methods

configure

Configures component by passing configuration parameters.

@override

void configure(ConfigParams config)

  • config: ConfigParams - configuration parameters to be set.

register

Registers all controller routes in HTTP endpoint.

@override

void register()

Examples

var controller = HeartbeatController();
controller.configure(ConfigParams.fromTuples(
    'route', 'ping',
    'connection.protocol', 'http',
    'connection.host', 'localhost',
    'connection.port', 8080
));

await controller.open('123');

print('The Heartbeat controller is accessible at http://+:8080/ping');

See also