Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ConnectionParams

Contains connection parameters to connect to external services. They are used together with credential parameters, but usually stored separately from more protected sensitive values.

Configuration parameters

  • discovery_key: key to retrieve parameters from discovery service
  • protocol: connection protocol like http, https, tcp, udp
  • host: host name or IP address
  • port: port number
  • uri: resource URI or connection string with all parameters in it

In addition to standard parameters ConnectionParams may contain any number of custom parameters

see

ConfigParams

see

CredentialParams

see

ConnectionResolver

see

IDiscovery

Example

Example ConnectionParams object usage:

let connection = ConnectionParams.fromTuples(
    "protocol", "http",
    "host", "10.1.1.100",
    "port", "8080",
    "cluster", "mycluster"
);

let host = connection.getHost();                             // Result: "10.1.1.100"
let port = connection.getPort();                             // Result: 8080
let cluster = connection.getAsNullableString("cluster");     // Result: "mycluster"

Hierarchy

Index

Constructors

constructor

  • Creates a new connection parameters and fills it with values.

    Parameters

    • Default value values: any = null

      (optional) an object to be converted into key-value pairs to initialize this connection.

    Returns ConnectionParams

Methods

getDiscoveryKey

  • getDiscoveryKey(): string
  • Gets the key to retrieve this connection from [[DiscoveryService]]. If this key is null, than all parameters are already present.

    see

    useDiscovery

    Returns string

    the discovery key to retrieve connection.

getHost

  • getHost(): string
  • Gets the host name or IP address.

    Returns string

    the host name or IP address.

getPort

  • getPort(): number
  • Gets the port number.

    Returns number

    the port number.

getPortWithDefault

  • getPortWithDefault(defaultPort: number): number
  • Gets the port number with default value.

    Parameters

    • defaultPort: number

      a default port number.

    Returns number

    the port number.

getProtocol

  • getProtocol(): string
  • Gets the connection protocol.

    Returns string

    the connection protocol or the default value if it's not set.

getProtocolWithDefault

  • getProtocolWithDefault(defaultValue: string): string
  • Gets the connection protocol with default value.

    Parameters

    • defaultValue: string

      (optional) the default protocol

    Returns string

    the connection protocol or the default value if it's not set.

getUri

  • getUri(): string
  • Gets the resource URI or connection string. Usually it includes all connection parameters in it.

    Returns string

    the resource URI or connection string.

setDiscoveryKey

  • setDiscoveryKey(value: string): void
  • Sets the key to retrieve these parameters from [[DiscoveryService]].

    Parameters

    • value: string

      a new key to retrieve connection.

    Returns void

setHost

  • setHost(value: string): void
  • Sets the host name or IP address.

    Parameters

    • value: string

      a new host name or IP address.

    Returns void

setPort

  • setPort(value: number): void
  • Sets the port number.

    see

    getHost

    Parameters

    • value: number

      a new port number.

    Returns void

setProtocol

  • setProtocol(value: string): void
  • Sets the connection protocol.

    Parameters

    • value: string

      a new connection protocol.

    Returns void

setUri

  • setUri(value: string): void
  • Sets the resource URI or connection string.

    Parameters

    • value: string

      a new resource URI or connection string.

    Returns void

useDiscovery

  • useDiscovery(): boolean
  • Checks if these connection parameters shall be retrieved from [[DiscoveryService]]. The connection parameters are redirected to [[DiscoveryService]] when discovery_key parameter is set.

    see

    getDiscoveryKey

    Returns boolean

    true if connection shall be retrieved from [[DiscoveryService]]

Static fromConfig

  • Retrieves a single ConnectionParams from configuration parameters from "connection" section. If "connections" section is present instead, then is returns only the first connection element.

    see

    manyFromConfig

    Parameters

    • config: ConfigParams

      ConnectionParams, containing a section named "connection(s)".

    Returns ConnectionParams

    the generated ConnectionParams object.

Static fromString

  • Creates a new ConnectionParams object filled with key-value pairs serialized as a string.

    see

    [[StringValueMap.fromString]]

    Parameters

    • line: string

      a string with serialized key-value pairs as "key1=value1;key2=value2;..." Example: "Key1=123;Key2=ABC;Key3=2016-09-16T00:00:00.00Z"

    Returns ConnectionParams

    a new ConnectionParams object.

Static fromTuples

  • Creates a new ConnectionParams object filled with provided key-value pairs called tuples. Tuples parameters contain a sequence of key1, value1, key2, value2, ... pairs.

    Parameters

    • Rest ...tuples: any[]

      the tuples to fill a new ConnectionParams object.

    Returns ConnectionParams

    a new ConnectionParams object.

Static manyFromConfig

  • Retrieves all ConnectionParams from configuration parameters from "connections" section. If "connection" section is present instead, than it returns a list with only one ConnectionParams.

    Parameters

    • config: ConfigParams

      a configuration parameters to retrieve connections

    Returns ConnectionParams[]

    a list of retrieved ConnectionParams

Generated using TypeDoc