The DTS Go SDK supports initializing the client through a Session. A DTS client created through a session reuses underlying HTTP/HTTPS resources (connections or requests). When you need to initialize multiple clients for operations, creating them through a session can improve client performance. This topic describes how to initialize the client through a session.
Prerequisites
- Before initializing the client, make sure that you have obtained the following information:
- The Access Key ID (AK) and Secret Access Key (SK) information of the account. For instructions on how to obtain AKSK information, refer to Viewing AKSK information.
- Region information. For the Regions supported by DTS, refer to Service address.
Initialize client
DT) supports two AK and SK configuration methods. During verification and testing phases, you can configure AK and SK in the Demo. If you need to publish to the production environment, configure AK and SK in the environment variables.
warning
During the call, the system automatically reads the configuration parameters. The AK and SK priorities configured in the debug code are higher than the configuration in environment variables.
Configure AK and SK in environment variables
Select a method to configure AK and SK based on your operating system.
- Linux or macOS operating system
- Execute the command below in the terminal with the prepared AK and SK.
export VOLC_ACCESSKEY="ak"
export VOLC_SECRETKEY="sk"
- Windows operating system
- Create a new system environment variable. Add the environment variables VOLC_ACCESSKEY and VOLC_SECRETKEY, then provide your prepared AK and SK.
Configure AK and SK in the Demo
This method poses potential security risks. Therefore, do not configure AK/SK in plaintext for production environments.
Provide AK and SK parameters with each call to DTS-related functions, suitable for rapid validation and testing.
instance := dts_v20221001.NewInstance()
instance.SetCredential(base.Credentials{