15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_SESSION_POOL_OPTIONS_H 16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_SESSION_POOL_OPTIONS_H 59 min_sessions_ = (std::max)(min_sessions_, 0);
60 max_sessions_per_channel_ = (std::max)(max_sessions_per_channel_, 1);
62 (std::min)(min_sessions_, max_sessions_per_channel_ * num_channels);
63 max_idle_sessions_ = (std::max)(max_idle_sessions_, 0);
74 min_sessions_ = count;
86 max_sessions_per_channel_ = count;
98 max_idle_sessions_ = count;
107 action_on_exhaustion_ = action;
116 return action_on_exhaustion_;
126 keep_alive_interval_ = interval;
132 return keep_alive_interval_;
142 labels_ = std::move(labels);
147 std::map<std::string, std::string>
const&
labels()
const {
return labels_; }
150 int min_sessions_ = 0;
151 int max_sessions_per_channel_ = 100;
152 int max_idle_sessions_ = 0;
154 std::chrono::seconds keep_alive_interval_ = std::chrono::minutes(55);
155 std::map<std::string, std::string> labels_;
163 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_SESSION_POOL_OPTIONS_H SessionPoolOptions & set_max_idle_sessions(int count)
Set the maximum number of sessions to keep in the pool in an idle state.
SessionPoolOptions & set_labels(std::map< std::string, std::string > labels)
Set the labels used when creating sessions within the pool.
int min_sessions() const
Return the minimum number of sessions to keep in the pool.
SessionPoolOptions & set_keep_alive_interval(std::chrono::seconds interval)
ActionOnExhaustion action_on_exhaustion() const
Return the action to take (kBlock or kFail) when attempting to allocate a session when the pool is ex...
SessionPoolOptions & set_min_sessions(int count)
Set the minimum number of sessions to keep in the pool.
Controls the session pool maintained by a spanner::Client.
std::map< std::string, std::string > const & labels() const
Return the labels used when creating sessions within the pool.
int max_sessions_per_channel() const
Return the minimum number of sessions to keep in the pool.
SessionPoolOptions & EnforceConstraints(int num_channels)
Enforce the stated constraints on the option values, altering them if necessary.
Contains all the Cloud Spanner C++ client types and functions.
int max_idle_sessions() const
Return the maximum number of idle sessions to keep in the pool.
SessionPoolOptions & set_max_sessions_per_channel(int count)
Set the maximum number of sessions to create on each channel.
#define SPANNER_CLIENT_NS
SessionPoolOptions & set_action_on_exhaustion(ActionOnExhaustion action)
Set whether to block or fail on pool exhaustion.
std::chrono::seconds keep_alive_interval() const
Return the interval at which we refresh sessions to prevent GC.