Esempio n. 1
0
 public Transaction(
     IConnectionLease connectionLease,
     DbTransaction transaction,
     IQueryProviderCommon queryProvider
     )
 {
     _connectionLease = connectionLease;
     _transaction     = transaction;
     _queryProvider   = queryProvider;
 }
Esempio n. 2
0
        private void ConnectionLeased(
            IPEndPoint host,
            IActorRef router,
            BongoSimpleClient client,
            IConnectionLease lease)
        {
            Receive <ConnectionLeaseRelease>(release =>
            {
                if (release.Lease != lease)
                {
                    return;
                }

                Become(() => WaitForLease(host, router, client));
                Stash.UnstashAll();
            });

            ReceiveAsync <LeaseQuery>(async query =>
            {
                if (query.ConnectionLeaseId != lease.ConnectionLeaseId)
                {
                    Sender.Tell(new LeaseRejection());
                    return;
                }

                try
                {
                    var response = await client.Query(query.Query);
                    Sender.Tell(response);
                }
                catch (BeeswaxException e)
                {
                    Sender.Tell(e);
                }
                catch (Exception e)
                {
                    Context.GetLogger().Error(e, "Error in connection");
                    Sender.Tell(e);

                    router.Tell(new RemoveRoutee(_routee));

                    Become(() => InitializeConnection(host, router));
                    Stash.UnstashAll();
                }
            });

            ReceiveAsync <LeaseInsert>(async query =>
            {
                if (query.ConnectionLeaseId != lease.ConnectionLeaseId)
                {
                    Sender.Tell(new LeaseRejection());
                    return;
                }

                try
                {
                    await client.Insert(query.Insert);
                    Sender.Tell(new LeaseInsertSuccess());
                }
                catch (BeeswaxException e)
                {
                    Sender.Tell(e);
                }
                catch (Exception e)
                {
                    Context.GetLogger().Error(e, "Error in connection");
                    Sender.Tell(e);

                    router.Tell(new RemoveRoutee(_routee));

                    Become(() => InitializeConnection(host, router));
                    Stash.UnstashAll();
                }
            });

            ReceiveAny(_ => Stash.Stash());

            Sender.Tell(lease);
        }
Esempio n. 3
0
 public QueryResult(DbCommand command, DbDataReader reader, IConnectionLease connectionLease)
 {
     _command         = command;
     _reader          = reader;
     _connectionLease = connectionLease;
 }
Esempio n. 4
0
 public ConnectionLeaseRelease(IConnectionLease lease)
 {
     Lease = lease;
 }