Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HttpConnectionResolver

Helper class to retrieve connections for HTTP-based services abd clients.

In addition to regular functions of ConnectionResolver is able to parse http:// URIs and validate connection parameters before returning them.

Configuration parameters

  • connection:

    • discovery_key: (optional) a key to retrieve the connection from IDiscovery
    • ... other connection parameters
  • connections: alternative to connection

    • [connection params 1]: first connection parameters
    • ...
    • [connection params N]: Nth connection parameters
    • ...

References

  • *:discovery:*:*:1.0 (optional) IDiscovery services
see

ConnectionParams

see

ConnectionResolver

Example

let config = ConfigParams.fromTuples(
     "connection.host", "10.1.1.100",
     "connection.port", 8080
);

let connectionResolver = new HttpConnectionResolver();
connectionResolver.configure(config);
connectionResolver.setReferences(references);

connectionResolver.resolve("123", (err, connection) => {
     // Now use connection...
});

Hierarchy

  • HttpConnectionResolver

Implements

  • any
  • any

Index

Properties

Protected _connectionResolver

_connectionResolver: ConnectionResolver = new ConnectionResolver()

The base connection resolver.

Protected _credentialResolver

_credentialResolver: CredentialResolver = new CredentialResolver()

The base credential resolver.

Methods

configure

  • configure(config: ConfigParams): void
  • Configures component by passing configuration parameters.

    Parameters

    • config: ConfigParams

      configuration parameters to be set.

    Returns void

register

  • register(correlationId: string, callback: function): void
  • Registers the given connection in all referenced discovery services. This method can be used for dynamic service discovery.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • callback: function

      callback function that receives registered connection or error.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

resolve

  • resolve(correlationId: string, callback: function): void
  • Resolves a single component connection. If connections are configured to be retrieved from Discovery service it finds a IDiscovery and resolves the connection there.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • callback: function

      callback function that receives resolved connection or error.

        • (err: any, connection: ConnectionParams, credential: CredentialParams): void
        • Parameters

          • err: any
          • connection: ConnectionParams
          • credential: CredentialParams

          Returns void

    Returns void

resolveAll

  • resolveAll(correlationId: string, callback: function): void
  • Resolves all component connection. If connections are configured to be retrieved from Discovery service it finds a IDiscovery and resolves the connection there.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • callback: function

      callback function that receives resolved connections or error.

        • (err: any, connections: ConnectionParams[], credential: CredentialParams): void
        • Parameters

          • err: any
          • connections: ConnectionParams[]
          • credential: CredentialParams

          Returns void

    Returns void

setReferences

  • setReferences(references: IReferences): void
  • Sets references to dependent components.

    Parameters

    • references: IReferences

      references to locate the component dependencies.

    Returns void

Generated using TypeDoc