Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ConnectionResolver

Helper class to retrieve component connections.

If connections are configured to be retrieved from IDiscovery, it automatically locates IDiscovery in component references and retrieve connections from there using discovery_key parameter.

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 parameters for key 1
    • [connection params N]: Nth connection parameters
      • ... connection parameters for key N

References

  • *:discovery:*:*:1.0 (optional) IDiscovery services to resolve connections
see

ConnectionParams

see

IDiscovery

Example

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

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

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

Hierarchy

  • ConnectionResolver

Index

Constructors

constructor

  • new ConnectionResolver(config?: ConfigParams, references?: IReferences): ConnectionResolver
  • Creates a new instance of connection resolver.

    Parameters

    • Default value config: ConfigParams = null

      (optional) component configuration parameters

    • Default value references: IReferences = null

      (optional) component references

    Returns ConnectionResolver

Methods

add

configure

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

    Parameters

    • config: ConfigParams

      configuration parameters to be set.

    Returns void

getAll

  • Gets all connections configured in component configuration.

    Redirect to Discovery services is not done at this point. If you need fully fleshed connection use resolve method instead.

    Returns ConnectionParams[]

    a list with connection parameters

register

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

    see

    IDiscovery

    Parameters

    • correlationId: string

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

    • connection: ConnectionParams

      a connection to register.

    • 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.

    see

    IDiscovery

    Parameters

    • correlationId: string

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

    • callback: function

      callback function that receives resolved connection or error.

    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.

    see

    IDiscovery

    Parameters

    • correlationId: string

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

    • callback: function

      callback function that receives resolved connections or error.

    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