2020#include " google/cloud/spanner/internal/session.h"
2121#include " google/cloud/spanner/internal/spanner_stub.h"
2222#include " google/cloud/spanner/retry_policy.h"
23+ #include " google/cloud/spanner/session_pool_options.h"
2324#include " google/cloud/spanner/version.h"
2425#include " google/cloud/status_or.h"
2526#include < google/spanner/v1/spanner.pb.h>
26- #include < chrono>
2727#include < condition_variable>
2828#include < cstddef>
2929#include < map>
@@ -39,34 +39,6 @@ namespace spanner {
3939inline namespace SPANNER_CLIENT_NS {
4040namespace internal {
4141
42- // What action to take if the session pool is exhausted.
43- enum class ActionOnExhaustion { BLOCK, FAIL };
44-
45- struct SessionPoolOptions {
46- // The minimum number of sessions to keep in the pool.
47- // Values <= 0 are treated as 0.
48- // This value will be reduced if it exceeds the overall limit on the number
49- // of sessions (`max_sessions_per_channel` * number of channels).
50- int min_sessions = 0 ;
51-
52- // The maximum number of sessions to create on each channel.
53- // Values <= 1 are treated as 1.
54- int max_sessions_per_channel = 100 ;
55-
56- // The maximum number of sessions that can be in the pool in an idle state.
57- // Values <= 0 are treated as 0.
58- int max_idle_sessions = 0 ;
59-
60- // Decide whether to block or fail on pool exhaustion.
61- ActionOnExhaustion action_on_exhaustion = ActionOnExhaustion::BLOCK;
62-
63- // This is the interval at which we refresh sessions so they don't get
64- // collected by the backend GC. The GC collects objects older than 60
65- // minutes, so any duration below that (less some slack to allow the calls
66- // to be made to refresh the sessions) should suffice.
67- std::chrono::minutes keep_alive_interval = std::chrono::minutes(55 );
68- };
69-
7042/* *
7143 * Maintains a pool of `Session` objects.
7244 *
@@ -90,9 +62,9 @@ class SessionPool : public std::enable_shared_from_this<SessionPool> {
9062 * create them. `stubs` must not be empty.
9163 */
9264 SessionPool (Database db, std::vector<std::shared_ptr<SpannerStub>> stubs,
65+ SessionPoolOptions options,
9366 std::unique_ptr<RetryPolicy> retry_policy,
94- std::unique_ptr<BackoffPolicy> backoff_policy,
95- SessionPoolOptions options = SessionPoolOptions());
67+ std::unique_ptr<BackoffPolicy> backoff_policy);
9668
9769 /* *
9870 * Allocate a `Session` from the pool, creating a new one if necessary.
@@ -130,6 +102,7 @@ class SessionPool : public std::enable_shared_from_this<SessionPool> {
130102 void Release (Session* session);
131103
132104 Status CreateSessions (std::unique_lock<std::mutex>& lk, ChannelInfo& channel,
105+ std::map<std::string, std::string> const & labels,
133106 int num_sessions); // EXCLUSIVE_LOCKS_REQUIRED(mu_)
134107
135108 SessionHolder MakeSessionHolder (std::unique_ptr<Session> session,
@@ -138,9 +111,9 @@ class SessionPool : public std::enable_shared_from_this<SessionPool> {
138111 void UpdateNextChannelForCreateSessions (); // EXCLUSIVE_LOCKS_REQUIRED(mu_)
139112
140113 Database const db_;
114+ SessionPoolOptions const options_;
141115 std::unique_ptr<RetryPolicy const > retry_policy_prototype_;
142116 std::unique_ptr<BackoffPolicy const > backoff_policy_prototype_;
143- SessionPoolOptions const options_;
144117 int const max_pool_size_;
145118
146119 std::mutex mu_;
0 commit comments