UNPKG

3.7 kBTypeScriptView Raw
1import { IReferences } from 'pip-services3-commons-node';
2import { ConfigParams } from 'pip-services3-commons-node';
3import { RestService } from './RestService';
4/**
5 * Service that returns microservice status information via HTTP/REST protocol.
6 *
7 * The service responds on /status route (can be changed) with a JSON object:
8 * {
9 * - "id": unique container id (usually hostname)
10 * - "name": container name (from ContextInfo)
11 * - "description": container description (from ContextInfo)
12 * - "start_time": time when container was started
13 * - "current_time": current time in UTC
14 * - "uptime": duration since container start time in milliseconds
15 * - "properties": additional container properties (from ContextInfo)
16 * - "components": descriptors of components registered in the container
17 * }
18 *
19 * ### Configuration parameters ###
20 *
21 * - base_route: base route for remote URI
22 * - route: status route (default: "status")
23 * - dependencies:
24 * - endpoint: override for HTTP Endpoint dependency
25 * - controller: override for Controller dependency
26 * - connection(s):
27 * - 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]]
28 * - protocol: connection protocol: http or https
29 * - host: host name or IP address
30 * - port: port number
31 * - uri: resource URI or connection string with all parameters in it
32 *
33 * ### References ###
34 *
35 * - <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
36 * - <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
37 * - <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
38 * - <code>\*:endpoint:http:\*:1.0</code> (optional) [[HttpEndpoint]] reference
39 *
40 * @see [[RestService]]
41 * @see [[RestClient]]
42 *
43 * ### Example ###
44 *
45 * let service = new StatusService();
46 * service.configure(ConfigParams.fromTuples(
47 * "connection.protocol", "http",
48 * "connection.host", "localhost",
49 * "connection.port", 8080
50 * ));
51 *
52 * service.open("123", (err) => {
53 * console.log("The Status service is accessible at http://+:8080/status");
54 * });
55 */
56export declare class StatusRestService extends RestService {
57 private _startTime;
58 private _references2;
59 private _contextInfo;
60 private _route;
61 /**
62 * Creates a new instance of this service.
63 */
64 constructor();
65 /**
66 * Configures component by passing configuration parameters.
67 *
68 * @param config configuration parameters to be set.
69 */
70 configure(config: ConfigParams): void;
71 /**
72 * Sets references to dependent components.
73 *
74 * @param references references to locate the component dependencies.
75 */
76 setReferences(references: IReferences): void;
77 /**
78 * Registers all service routes in HTTP endpoint.
79 */
80 register(): void;
81 /**
82 * Handles status requests
83 *
84 * @param req an HTTP request
85 * @param res an HTTP response
86 */
87 private status;
88}