SqlServerConnectionResolver

Helper class that resolves a SqlServer connection and credential parameters, validates them and generates a connection URI.

Implements: IReferenceable, IConfigurable

Description

The SqlServerConnectionResolver class is used to resolve SqlServer connections and credential paramters, validate them and generate connection URIs.

Important points

  • It is able to process multiple connections to SqlServer cluster nodes.

Configuration parameters

  • connection(s):
    • discovery_key: (optional) a key to retrieve the connection from IDiscovery
    • host: host name or IP address
    • port: port number (default: 8082)
    • database: database name
    • 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
  • *:credential-store:*:*:1.0 - (optional) ICredentialStore stores to resolve credentials

Constructors

NewSqlServerConnectionResolver

Creates a new instance of this class.

NewSqlServerConnectionResolver() *SqlServerConnectionResolver

Fields

ConnectionResolver

Connection resolver

ConnectionResolver: ConnectionResolver

CredentialResolver

Credential resolver

CredentialResolver: CredentialResolver

Methods

Configure

Configures a component by passing its configuration parameters.

(c *SqlServerConnectionResolver) Configure(ctx context.Context, config *cconf.ConfigParams)

  • ctx: context.Context - operation context.
  • config: *cconf.ConfigParams - configuration parameters to be set.

Resolve

Resolves a SqlServer connection URI from connection and credential parameters.

(c *SqlServerConnectionResolver) Resolve(ctx context.Context, context IContext) (config map[string]any, err error)

  • ctx: context.Context - operation context.
  • context: IContext - (optional) a context to trace execution through a call chain.
  • returns: (config map[string]any, err error) - resolved config.

SetReferences

Sets references to dependent components.

(c *SqlServerConnectionResolver) SetReferences(ctx context.Context, references crefer.IReferences)

  • ctx: context.Context - operation context.
  • references: crefer.IReferences - references to locate the component’s dependencies.