/// <summary> /// Creates a session pool for the given client. /// </summary> /// <param name="client">The client to use for this session pool. Must not be null.</param> /// <param name="options">The options for this session pool. Must not be null.</param> /// <param name="logger">The logger to use. May be null, in which case the default logger is used.</param> public SessionPool(SpannerClient client, SessionPoolOptions options, Logger logger) { _client = GaxPreconditions.CheckNotNull(client, nameof(client)); _clock = _client.Settings.Clock ?? SystemClock.Instance; _scheduler = _client.Settings.Scheduler ?? SystemScheduler.Instance; Options = GaxPreconditions.CheckNotNull(options, nameof(options)); _logger = logger ?? Logger.DefaultLogger; _detachedSessionPool = new DetachedSessionPool(this); _sessionAcquisitionSemaphore = new SemaphoreSlim(Options.MaximumConcurrentSessionCreates); if (Options.MaintenanceLoopDelay != TimeSpan.Zero) { Task.Run(() => PoolMaintenanceLoop(this)); } }
/// <summary> /// Creates a session pool for the given client. /// </summary> /// <param name="client">The client to use for this session pool. Must not be null.</param> /// <param name="options">The options for this session pool. Must not be null.</param> public SessionPool(SpannerClient client, SessionPoolOptions options) { Client = GaxPreconditions.CheckNotNull(client, nameof(client)); _clock = client.Settings.Clock ?? SystemClock.Instance; _scheduler = client.Settings.Scheduler ?? SystemScheduler.Instance; Options = GaxPreconditions.CheckNotNull(options, nameof(options)); _logger = client.Settings.Logger; // Just to avoid fetching it all the time _detachedSessionPool = new DetachedSessionPool(this); _batchSessionCreateSemaphore = new SemaphoreSlim((int)Math.Ceiling( Options.MaximumConcurrentSessionCreates / (double)Options.CreateSessionMaximumBatchSize)); if (Options.MaintenanceLoopDelay != TimeSpan.Zero) { Task.Run(() => PoolMaintenanceLoop(this)); } }
internal SessionPoolImpl(SessionPoolKey key, SessionPoolOptions options) { _options = GaxPreconditions.CheckNotNull(options, nameof(options)); _sessionCreateThrottle = new SemaphoreSlim(_options.MaximumConcurrentSessionCreates, _options.MaximumConcurrentSessionCreates); Key = key; }