1 | /** @module services */
|
2 | import { RestService } from './RestService';
|
3 | import { ConfigParams } from 'pip-services3-commons-node';
|
4 | /**
|
5 | * Service returns heartbeat via HTTP/REST protocol.
|
6 | *
|
7 | * The service responds on /heartbeat route (can be changed)
|
8 | * with a string with the current time in UTC.
|
9 | *
|
10 | * This service route can be used to health checks by loadbalancers and
|
11 | * container orchestrators.
|
12 | *
|
13 | * ### Configuration parameters ###
|
14 | *
|
15 | * - base_route: base route for remote URI (default: "")
|
16 | * - route: route to heartbeat operation (default: "heartbeat")
|
17 | * - dependencies:
|
18 | * - endpoint: override for HTTP Endpoint dependency
|
19 | * - connection(s):
|
20 | * - discovery_key: (optional) a key to retrieve the connection from [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]]
|
21 | * - protocol: connection protocol: http or https
|
22 | * - host: host name or IP address
|
23 | * - port: port number
|
24 | * - uri: resource URI or connection string with all parameters in it
|
25 | *
|
26 | * ### References ###
|
27 | *
|
28 | * - <code>\*:logger:\*:\*:1.0</code> (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/log.ilogger.html ILogger]] components to pass log messages
|
29 | * - <code>\*:counters:\*:\*:1.0</code> (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/count.icounters.html ICounters]] components to pass collected measurements
|
30 | * - <code>\*:discovery:\*:\*:1.0</code> (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] services to resolve connection
|
31 | * - <code>\*:endpoint:http:\*:1.0</code> (optional) [[HttpEndpoint]] reference
|
32 | *
|
33 | * @see [[RestService]]
|
34 | * @see [[RestClient]]
|
35 | *
|
36 | * ### Example ###
|
37 | *
|
38 | * let service = new HeartbeatService();
|
39 | * service.configure(ConfigParams.fromTuples(
|
40 | * "route", "ping",
|
41 | * "connection.protocol", "http",
|
42 | * "connection.host", "localhost",
|
43 | * "connection.port", 8080
|
44 | * ));
|
45 | *
|
46 | * service.open("123", (err) => {
|
47 | * console.log("The Heartbeat service is accessible at http://+:8080/ping");
|
48 | * });
|
49 | */
|
50 | export declare class HeartbeatRestService extends RestService {
|
51 | private _route;
|
52 | /**
|
53 | * Creates a new instance of this service.
|
54 | */
|
55 | constructor();
|
56 | /**
|
57 | * Configures component by passing configuration parameters.
|
58 | *
|
59 | * @param config configuration parameters to be set.
|
60 | */
|
61 | configure(config: ConfigParams): void;
|
62 | /**
|
63 | * Registers all service routes in HTTP endpoint.
|
64 | */
|
65 | register(): void;
|
66 | /**
|
67 | * Handles heartbeat requests
|
68 | *
|
69 | * @param req an HTTP request
|
70 | * @param res an HTTP response
|
71 | */
|
72 | private heartbeat;
|
73 | }
|