HttpConnectionResolver

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

Inherits: IReferenceable, IConfigurable

Description

The HttpConnectionResolver class is used to retrieve connections for HTTP-based services and clients.

Important points

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

Configuration parameters

  • connection:
    • discovery_key: (optional) 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 to resolve a connection

Fields

_connectionResolver

Creates a connection resolver.

protected _credentialResolver: ConnectionResolver = ConnectionResolver()

_credentialResolver

Base credential resolver.

protected _credentialResolver: CredentialResolver = CredentialResolver()

Instance methods

Configure

Configures a component by passing its configuration parameters.

public void Configure(ConfigParams config)

  • config: ConfigParams - configuration parameters to be set.

RegisterAsync

Registers the given connection in all referenced discovery services. This method can be used for dynamic service discovery.

public Task RegisterAsync(string correlationId)

  • correlationId: string - (optional) transaction id used to trace execution through the call chain.

ResolveAsync

Resolves a single component connection. If the connections are configured to be retrieved from Discovery service, it finds a IDiscovery and resolves the connection there.

public Task<ConnectionParams> ResolveAsync(string correlationId)

  • correlationId: string - (optional) transaction id used to trace execution through the call chain.
  • returns: Task<ConnectionParams> - resolved connection.

ResolveAllAsync

Resolves all component connections. If the connections are configured to be retrieved from a Discovery service it finds a IDiscovery and resolves the connection there.

public Task<List<ConnectionParams>> ResolveAllAsync(string correlationId)

  • correlationId: string - (optional) transaction id used to trace execution through the call chain.
  • returns: Task<List<ConnectionParams>> - resolved connections.

SetReferences

Sets references to dependent components.

public void SetReferences(IReferences references)

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

Examples

var config = ConfigParams.FromTuples(
    "connection.host", "10.1.1.100",
    "connection.port", 8080 );

var connectionResolver = new HttpConnectionResolver();
connectionResolver.Configure(config);
connectionResolver.SetReferences(references);

var params = connectionResolver.ResolveAsync("123");

See also