Esempio n. 1
0
        public ModelWrapper Create()
        {
            foreach (var connection in this.connections)
            {
                (bool success, ModelWrapper model) = connection.Get();
                if (success)
                {
                    return(model);
                }
            }

            this.semaphoreSlim.Wait();
            try
            {
                if (this.connections.Count < this.options.MaxConnection)
                {
                    var connection = new ConnectionWrapper(this.connectionFactory.CreateConnection(this.options.EndPoints), this.options);
                    (bool success, ModelWrapper model) = connection.Get();
                    this.connections.Add(connection);
                    if (success)
                    {
                        return(model);
                    }
                }

                throw new System.OverflowException(nameof(this.connections));
            }
            finally
            {
                this.semaphoreSlim.Release();
            }
        }
Esempio n. 2
0
 public ModelWrapper(
     ConnectionWrapper connectionWrapper,
     IModel model)
 {
     this.Connection                        = connectionWrapper;
     this.Model                             = model;
     this.persistentProperties              = this.Model.CreateBasicProperties();
     this.persistentProperties.Persistent   = true;
     this.noPersistentProperties            = this.Model.CreateBasicProperties();
     this.noPersistentProperties.Persistent = false;
 }