1 | import { IReferenceable } from 'pip-services3-commons-node';
|
2 | import { IReferences } from 'pip-services3-commons-node';
|
3 | import { IConfigurable } from 'pip-services3-commons-node';
|
4 | import { ConfigParams } from 'pip-services3-commons-node';
|
5 | import { ConnectionResolver } from 'pip-services3-components-node';
|
6 | import { ConnectionParams } from 'pip-services3-components-node';
|
7 | import { CredentialResolver } from 'pip-services3-components-node';
|
8 | import { CredentialParams } from 'pip-services3-components-node';
|
9 | /**
|
10 | * Helper class to retrieve connections for HTTP-based services abd clients.
|
11 | *
|
12 | * In addition to regular functions of ConnectionResolver is able to parse http:// URIs
|
13 | * and validate connection parameters before returning them.
|
14 | *
|
15 | * ### Configuration parameters ###
|
16 | *
|
17 | * - connection:
|
18 | * - 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]]
|
19 | * - ... other connection parameters
|
20 | *
|
21 | * - connections: alternative to connection
|
22 | * - [connection params 1]: first connection parameters
|
23 | * - ...
|
24 | * - [connection params N]: Nth connection parameters
|
25 | * - ...
|
26 | *
|
27 | * ### References ###
|
28 | *
|
29 | * - <code>\*:discovery:\*:\*:1.0</code> (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] services
|
30 | *
|
31 | * @see [[https://pip-services3-node.github.io/pip-services3-components-node/classes/connect.connectionparams.html ConnectionParams]]
|
32 | * @see [[https://pip-services3-node.github.io/pip-services3-components-node/classes/connect.connectionresolver.html ConnectionResolver]]
|
33 | *
|
34 | * ### Example ###
|
35 | *
|
36 | * let config = ConfigParams.fromTuples(
|
37 | * "connection.host", "10.1.1.100",
|
38 | * "connection.port", 8080
|
39 | * );
|
40 | *
|
41 | * let connectionResolver = new HttpConnectionResolver();
|
42 | * connectionResolver.configure(config);
|
43 | * connectionResolver.setReferences(references);
|
44 | *
|
45 | * connectionResolver.resolve("123", (err, connection) => {
|
46 | * // Now use connection...
|
47 | * });
|
48 | */
|
49 | export declare class HttpConnectionResolver implements IReferenceable, IConfigurable {
|
50 | /**
|
51 | * The base connection resolver.
|
52 | */
|
53 | protected _connectionResolver: ConnectionResolver;
|
54 | /**
|
55 | * The base credential resolver.
|
56 | */
|
57 | protected _credentialResolver: CredentialResolver;
|
58 | /**
|
59 | * Configures component by passing configuration parameters.
|
60 | *
|
61 | * @param config configuration parameters to be set.
|
62 | */
|
63 | configure(config: ConfigParams): void;
|
64 | /**
|
65 | * Sets references to dependent components.
|
66 | *
|
67 | * @param references references to locate the component dependencies.
|
68 | */
|
69 | setReferences(references: IReferences): void;
|
70 | private validateConnection;
|
71 | private updateConnection;
|
72 | /**
|
73 | * Resolves a single component connection. If connections are configured to be retrieved
|
74 | * from Discovery service it finds a IDiscovery and resolves the connection there.
|
75 | *
|
76 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
77 | * @param callback callback function that receives resolved connection or error.
|
78 | */
|
79 | resolve(correlationId: string, callback: (err: any, connection: ConnectionParams, credential: CredentialParams) => void): void;
|
80 | /**
|
81 | * Resolves all component connection. If connections are configured to be retrieved
|
82 | * from Discovery service it finds a IDiscovery and resolves the connection there.
|
83 | *
|
84 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
85 | * @param callback callback function that receives resolved connections or error.
|
86 | */
|
87 | resolveAll(correlationId: string, callback: (err: any, connections: ConnectionParams[], credential: CredentialParams) => void): void;
|
88 | /**
|
89 | * Registers the given connection in all referenced discovery services.
|
90 | * This method can be used for dynamic service discovery.
|
91 | *
|
92 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
93 | * @param connection a connection to register.
|
94 | * @param callback callback function that receives registered connection or error.
|
95 | */
|
96 | register(correlationId: string, callback: (err: any) => void): void;
|
97 | }
|