CompositeConnectionResolver

Helper class that resolves connection and credential parameters, validates them and generates connection options.

Implements: IConfigurable, IReferenceable

Description

The CompositeConnectionResolver class allows you to resolve connection and credential parameters, validate them and generate connection options.

Configuration parameters

connection(s):

  • discovery_key: (optional) a key to retrieve the connection from IDiscovery
  • protocol: communication protocol
  • host: host name or IP address
  • port: port number
  • uri: resource URI or connection string with all parameters in it

credential(s):

  • store_key: (optional) a key to retrieve the credentials from ICredentialStore
  • username: user name
  • password: user password

References

  • *:discovery:*:*:1.0 - (optional) IDiscovery services to resolve connections
  • *:credential-store:*:*:1.0 - (optional) Credential stores to resolve credentials ICredentialStore

Fields

_options

The connection options

protected _options: ConfigParams

_connectionResolver

The connections resolver.

protected _connectionResolver: ConnectionResolver

_credentialResolver

The credentials resolver.

protected _credentialResolver: CredentialResolver

_clusterSupported

The cluster support (multiple connections)

protected _clusterSupported: boolean

_defaultProtocol

The default protocol

protected _defaultProtocol: string

_defaultPort

The default port

protected _defaultPort: number

_supported_protocols

The list of supported protocols

protected _supportedProtocols: string[]

Instance methods

compose

Composes Composite connection options from connection and credential parameters.

public compose(context: IContext, connections: ConnectionParams[], credential: CredentialParams, parameters: ConfigParams): ConfigParams

composeOptions

A composite of several merger options

protected composeOptions(connections: ConnectionParams[], credential: CredentialParams, parameters: ConfigParams): ConfigParams

configure

Configures component by passing configuration parameters.

public configure(config: ConfigParams): void

  • config: ConfigParams - configuration parameters to be set.

finalizeOptions

Finalize merged options. This method can be overriden in child classes.

protected finalizeOptions(options: ConfigParams): ConfigParams

mergeConnection

Merges connection options with connection parameters. This method can be overriden in child classes.

protected mergeConnection( options: ConfigParams, connection: ConnectionParams): ConfigParams

mergeCredential

Merges connection options with credential parameters. This method can be overriden in child classes.

protected mergeCredential(options: ConfigParams, credential: CredentialParams): ConfigParams

mergeOptional

Merges connection options with optional parameters. This method can be overriden in child classes.

protected mergeOptional(options: ConfigParams, parameters: ConfigParams): ConfigParams

resolve

Resolves connection options from connection and credential parameters.

public resolve(context: IContext): Promise<ConfigParams>

  • context: IContext - (optional) a context to trace execution through call chain.
  • returns: Promise<ConfigParams> - resolved options or error

setReferences

Sets references to dependent components.

public setReferences(references: IReferences): void

  • references: IReferences - references to locate the component dependencies.

validateConnection

Validates connection parameters. Throws error if validation failed. This method can be overriden in child classes.

protected validateConnection(context: IContext, connection: ConnectionParams): void

  • context: IContext - (optional) a context to trace execution through call chain.
  • connection: ConnectionParams - connection parameters to be validated

validateCredential

Validates credential parameters. This method can be overriden in child classes.

protected validateCredential(context: IContext, credential: CredentialParams): void

  • context: IContext - (optional) a context to trace execution through call chain.
  • credential: CredentialParams - credential parameters to be validated