in consumer/consumer_client.go [19:70]
func initConsumerClient(option LogHubConfig, logger log.Logger) *ConsumerClient {
// Setting configuration defaults
if option.HeartbeatIntervalInSecond == 0 {
option.HeartbeatIntervalInSecond = 20
}
if option.HeartbeatTimeoutInSecond == 0 {
option.HeartbeatTimeoutInSecond = option.HeartbeatIntervalInSecond * 3
}
if option.DataFetchIntervalInMs == 0 {
option.DataFetchIntervalInMs = 200
}
if option.MaxFetchLogGroupCount == 0 {
option.MaxFetchLogGroupCount = 1000
}
if option.AutoCommitIntervalInMS == 0 {
option.AutoCommitIntervalInMS = 60 * 1000
}
var client sls.ClientInterface
if option.CredentialsProvider != nil {
client = sls.CreateNormalInterfaceV2(option.Endpoint, option.CredentialsProvider)
} else {
client = sls.CreateNormalInterface(option.Endpoint,
option.AccessKeyID,
option.AccessKeySecret,
option.SecurityToken)
}
client.SetUserAgent(option.ConsumerGroupName + "_" + option.ConsumerName)
if option.HTTPClient != nil {
client.SetHTTPClient(option.HTTPClient)
}
if option.AuthVersion != "" {
client.SetAuthVersion(option.AuthVersion)
}
if option.Region != "" {
client.SetRegion(option.Region)
}
consumerGroup := sls.ConsumerGroup{
ConsumerGroupName: option.ConsumerGroupName,
Timeout: option.HeartbeatTimeoutInSecond,
InOrder: option.InOrder,
}
consumerClient := &ConsumerClient{
option,
client,
consumerGroup,
logger,
}
return consumerClient
}