This guide will walk you through the configuration options that allow you to fine-tune your DAX client's performance, connection management, and logging behavior. By understanding the default settings and how to customize them, you can optimize your Go application's interaction with DAX.
In this section
DAX Go SDK Client Defaults
Parameter | Type | Description |
---|---|---|
required |
|
The AWS Region to use for the DAX client (example- 'us-east-1'). This is a required parameter if not provided through the environment. |
required |
|
List of DAX cluster endpoints to which SDK connects. For example: Non-Encrypted – dax://my-cluster.l6fzcv.dax-clusters.us-east-1.amazonaws.com Encrypted – daxs://my-cluster.l6fzcv.dax-clusters.us-east-1.amazonaws.com |
default 10 |
|
Number of concurrent connection attempts. (Connections can be in the process of being established concurrently.) |
default 125 * time.Millisecond |
|
The minimum time that must elapse between cluster refreshes. |
default 4 * time.Second |
|
The interval at which the client will automatically refresh the DAX cluster information. |
default 30 * time.Second |
|
The interval at which the client will close idle connections in the DAX client. |
default 5 * time.Second |
|
The interval at which the client will perform health checks on the DAX cluster endpoints. |
default |
|
The AWS credentials used by the DAX client to authenticate requests to the DAX service. See Credentials and Credential Providers. |
default |
|
A custom function used by the DAX client to establish connections to the DAX cluster. |
default false |
bool |
Skip hostname verification of TLS connections. This setting only affects encrypted clusters. When set to True, it disables hostname verification. Disabling verification means you can't authenticate the identity of the cluster you're connecting to, which poses security risks. By default, hostname verification is enabled. |
default false |
|
This flag is used to remove routes facing network errors. |
default 60 * time.Second |
|
This defines the maximum time the client will wait for a response from DAX. Priority: Context timeout (if set) > |
default 2 |
|
The number of retries to attempt for write requests that fail. |
default 2 |
|
The number of retries to attempt for read requests that fail. |
default 0 |
|
The delay for non-throttled errors (in seconds) for retry attempts when a request fails. |
optional |
|
Logger is an interface for logging entries at certain classifications. |
default utils.LogOff |
|
This loglevel is defined for DAX only. It can be imported using github.com/aws/aws-dax-go-v2/tree/main/dax/utils
|
Note
For time.Duration
, the default unit is nanosecond. If we don’t specify any unit
for any parameter then it will consider that as nano seconds:
daxCfg.ClusterUpdateInterval = 10
means 10 nano
seconds. (daxCfg.ClusterUpdateInterval = 10 *
time.Millisecond
means 10 milliseconds).
Client creation
To create a DAX client:
-
Create DAX config, then create DAX client using DAX config. Using this, you can overwrite a DAX configuration if required.
import ( "github.com/aws/aws-dax-go-v2/dax/utils" "github.com/aws/aws-dax-go-v2/dax" ) // Non - Encrypted : 'dax://my-cluster.l6fzcv.dax-clusters.us-east-1.amazonaws.com'. // Encrypted : daxs://my-cluster.l6fzcv.dax-clusters.us-east-1.amazonaws.com'. config := dax.DefaultConfig() config.HostPorts = []string{endpoint} config.Region = region config.LogLevel = utils.LogDebug daxClient, err := dax.New(config)