func NewClientWithConfig()

in datahub/datahub.go [3:38]


func NewClientWithConfig(endpoint string, config *Config, account Account) DataHubApi {
	config.UserAgent = DefaultUserAgent() + " " + config.UserAgent
	if config.HttpClient == nil {
		config.HttpClient = DefaultHttpClient()
	}
	if !validateCompressorType(config.CompressorType) {
		config.CompressorType = NOCOMPRESS
	}

	dh := &DataHub{
		Client: NewRestClient(endpoint, config.UserAgent, config.HttpClient,
			account, config.CompressorType),
		cType: config.CompressorType,
	}

	if config.EnableSchemaRegistry {
		dh.schemaClient = NewSchemaClient(dh)

		// compress data in batch record, no need to compress http body
		if config.CompressorType != NOCOMPRESS {
			dh.Client.CompressorType = NOCOMPRESS
		}

		return &DataHubBatch{
			DataHub: *dh,
		}
	} else {
		if config.EnableBinary {
			return &DataHubPB{
				DataHub: *dh,
			}
		} else {
			return dh
		}
	}
}