Skip to main content

Configuration

Learn how to configure the Conviso Go SDK for your specific needs.

Basic Configuration​

The minimum configuration requires only your Conviso API key:

import "github.com/codematic/opencdp-go/cdp"

client := cdp.NewClient(cdp.CDPConfig{
CDPAPIKey: "your-cdp-api-key",
})

Configuration Examples​

Development Environment​

client := cdp.NewClient(cdp.CDPConfig{
CDPAPIKey: os.Getenv("CDP_API_KEY"),
Debug: true,
Timeout: 15000,
MaxConcurrentRequests: 5,
})

Production Environment​

client := cdp.NewClient(cdp.CDPConfig{
CDPAPIKey: os.Getenv("CDP_API_KEY"),
Debug: false,
Timeout: 10000,
MaxConcurrentRequests: 20,
})

Migration Scenario (Dual-Write)​

client := cdp.NewClient(cdp.CDPConfig{
CDPAPIKey: os.Getenv("CDP_API_KEY"),
SendToCustomerIO: true,
CustomerIO: &cdp.CustomerIOConfig{
SiteID: os.Getenv("CUSTOMERIO_SITE_ID"),
APIKey: os.Getenv("CUSTOMERIO_API_KEY"),
Region: "us",
},
FailOnException: false,
})

Configuration Options​

CDPConfig Struct​

type CDPConfig struct {
CDPAPIKey string
CDPEndpoint string // Optional
MaxConcurrentRequests int
Timeout int // ms
Logger Logger // Optional custom logger interface
FailOnException bool
Debug bool

// Dual-write config
SendToCustomerIO bool
CustomerIO *CustomerIOConfig
}

Required Options​

CDPAPIKey​

Your Conviso API key for authentication.

Keep Your API Key Secret

Never commit your API key to version control. Use environment variables.

Optional Conviso Settings​

CDPEndpoint​

Custom endpoint URL for the Conviso API. Defaults to https://api.opencdp.io/gateway/data-gateway.

CDPEndpoint: "https://custom-endpoint.example.com"

MaxConcurrentRequests​

Maximum number of concurrent requests to the Conviso API. Default: 10, Maximum: 30.

MaxConcurrentRequests: 20

Use case: Adjust based on your application's traffic patterns. The SDK uses a buffered channel semaphore to limit concurrency.

Timeout​

Timeout is in milliseconds. The built-in default is 10000 (10 seconds). A value of 0 or less also uses that default.

The timeout is how long the SDK waits for one gateway host to answer a single request. On a timeout, a network error, or a non-success status, the SDK tries the next host immediately:

  1. https://api.opencdp.io/gateway/data-gateway
  2. https://api.open-cdp.com/gateway/data-gateway
  3. https://api.open-cdp.xyz/gateway/data-gateway

To wait 5 seconds on each host, pass 5000:

Timeout: 5000 // 5 seconds

FailOnException​

If true, SDK methods will return an error when the API call fails or validation fails. If false, errors are logged but methods return nil (best-effort). Default: false.

FailOnException: true

Debug​

Enable debug logging for troubleshooting. Default: false.

Debug: true

Customer.io Dual-Write​

SendToCustomerIO​

Enable dual-write to Customer.io. Default: false.

SendToCustomerIO: true

CustomerIO​

Customer.io credentials for dual-write mode.

CustomerIO: &cdp.CustomerIOConfig{
SiteID: "your-site-id",
APIKey: "your-api-key",
Region: "us", // or "eu"
}

Connection Management​

The SDK automatically manages connections using Go's http.Client with custom transport settings:

  • MaxIdleConns: 100
  • IdleConnTimeout: 90 seconds

You should create one Client instance and reuse it throughout your application's lifecycle.

Next Steps​