Skip to content

Commit

Permalink
Pass proxy configuration in the Java wrapper to c++ library
Browse files Browse the repository at this point in the history
Added generated code
  • Loading branch information
Xin Gu committed Apr 15, 2021
1 parent d01a9de commit b62dbaa
Show file tree
Hide file tree
Showing 10 changed files with 3,725 additions and 2,408 deletions.
78 changes: 78 additions & 0 deletions aws/kinesis/core/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,36 @@ class Configuration : private boost::noncopyable {
return verify_certificate_;
}

/// If you have users going through a proxy, get the host here.
///
/// Default: ""
const std::string& proxy_host() const noexcept {
return proxy_host_;
}

/// If you have users going through a proxy, get the port here.
///
// Default: 443
// Minimum: 1
// Maximum (inclusive): 65535
size_t proxy_port() const noexcept {
return proxy_port_;
}

/// If you have users going through a proxy, get the user name here.
///
/// Default: ""
const std::string& proxy_user_name() const noexcept {
return proxy_user_name_;
}

/// If you have users going through a proxy, get the password here.
///
/// Default: ""
const std::string& proxy_password() const noexcept {
return proxy_password_;
}

/// Indicates whether the SDK clients should use a thread pool or not
/// \return true if the client should use a thread pool, false otherwise
bool use_thread_pool() const noexcept {
Expand Down Expand Up @@ -939,6 +969,46 @@ class Configuration : private boost::noncopyable {
return *this;
}

/// If you have users going through a proxy, set the host here.
///
/// Default: ""
Configuration& proxy_host(std::string val) {
proxy_host_ = val;
return *this;
}

/// If you have users going through a proxy, set the port here.
///
/// Default: 443
// Minimum: 1
// Maximum (inclusive): 65535
Configuration& proxy_port(size_t val) {
if (val < 1ull || val > 65535ull) {
std::string err;
err += "proxy_port must be between 1 and 65535, got ";
err += std::to_string(val);
throw std::runtime_error(err);
}
proxy_port_ = val;
return *this;
}

/// If you have users going through a proxy, set the user name here.
///
/// Default: ""
Configuration& proxy_user_name(std::string val) {
proxy_user_name_ = val;
return *this;
}

/// If you have users going through a proxy, set the password here.
///
/// Default: ""
Configuration& proxy_password(std::string val) {
proxy_password_ = val;
return *this;
}

/// Enables or disable the use of a thread pool for the SDK Client.
/// Default: false
/// \param val whether or not to use a thread pool
Expand Down Expand Up @@ -1004,6 +1074,10 @@ class Configuration : private boost::noncopyable {
region(c.region());
request_timeout(c.request_timeout());
verify_certificate(c.verify_certificate());
proxy_host(c.proxy_host());
proxy_port(c.proxy_port());
proxy_user_name(c.proxy_user_name());
proxy_password(c.proxy_password());
if (c.thread_config() == ::aws::kinesis::protobuf::Configuration_ThreadConfig::Configuration_ThreadConfig_POOLED) {
use_thread_pool(true);
thread_pool_size(c.thread_pool_size());
Expand Down Expand Up @@ -1045,6 +1119,10 @@ class Configuration : private boost::noncopyable {
std::string region_ = "";
uint64_t request_timeout_ = 6000;
bool verify_certificate_ = true;
std::string proxy_host_ = "";
size_t proxy_port_ = 443;
std::string proxy_user_name_ = "";
std::string proxy_password_ = "";

bool use_thread_pool_ = true;
uint32_t thread_pool_size_ = 64;
Expand Down
4 changes: 4 additions & 0 deletions aws/kinesis/core/kinesis_producer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ make_sdk_client_cfg(const aws::kinesis::core::Configuration& kpl_cfg,
cfg.requestTimeoutMs = cast_size_t<long>(kpl_cfg.request_timeout());
cfg.connectTimeoutMs = cast_size_t<long>(kpl_cfg.connect_timeout());
cfg.retryStrategy = std::make_shared<Aws::Client::DefaultRetryStrategy>(retryCount);
cfg.proxyHost = kpl_cfg.proxy_host();
cfg.proxyPort = cast_size_t<unsigned>(kpl_cfg.proxy_port());
cfg.proxyUserName = kpl_cfg.proxy_user_name();
cfg.proxyPassword = kpl_cfg.proxy_password();
if (kpl_cfg.use_thread_pool()) {
if (sdk_client_executor == nullptr) {
uint32_t thread_pool_size = kpl_cfg.thread_pool_size();
Expand Down
Loading

0 comments on commit b62dbaa

Please sign in to comment.