Exemplo n.º 1
0
 private void WaitForLease(IPEndPoint host, IActorRef router, BongoSimpleClient client)
 {
     Receive <ConnectionLeaseRequest>(request =>
     {
         var lease = new ConnectionLease(Self, Sender);
         Become(() => ConnectionLeased(host, router, client, lease));
     });
 }
Exemplo n.º 2
0
        private async Task CreateTable(ConnectionLease client, Type type)
        {
            var createString = GetCreateTable(type);
            var response     = await client.Connection.Ask(new LeaseQuery(createString, client.ConnectionLeaseId));

            switch (response)
            {
            case QueryResponse queryResponse:
                return;

            case Exception exception:
                throw exception;
            }
        }
Exemplo n.º 3
0
        public void Should_lease_connection_from_pool_and_insert_rows()
        {
            var now          = DateTimeOffset.Now;
            var tableManager = CreateTestProbe();

            var bucketSize = (long)TimeSpan.FromDays(30).TotalMilliseconds;
            var start      = now.ToUnixTimeMilliseconds() / bucketSize * bucketSize;

            var itemToInsert = new BulkInsertManagerTests_Item
            {
                Id   = 43252435,
                Time = now
            };

            _actor.Tell(new InsertRequest(new List <object>
            {
                itemToInsert
            }));

            _tablesManagerProbe.ExpectMsg <TableManagerRequest>();

            _actor.Tell(new TableManagerResponse(tableManager));

            tableManager.ExpectMsg <PartitionInformationRequest>();

            _actor.Tell(new PartitionInformation
            {
                HashPartition   = null,
                RangePartitions = new List <RangePartition>
                {
                    new RangePartition(start, start + bucketSize)
                }
            });

            _poolManagerProbe.ExpectMsg <ConnectionLeaseRequest>();

            var connectionProbe = CreateTestProbe();

            var connection = new ConnectionLease(connectionProbe, _actor);

            _actor.Tell(connection);

            connectionProbe.ExpectMsg <LeaseInsert>((insertQuery, sender) =>
            {
                insertQuery.Insert
                .Should()
                .Be($@"
insert into
    default.BulkInsertManagerTests_Item
        (id, at_time)
values
    ({itemToInsert.Id},{itemToInsert.Time.ToUnixTimeMilliseconds()});
");

                sender.Tell(new LeaseInsertSuccess());
            });

            connectionProbe.ExpectMsg <ConnectionLeaseRelease>();

            ExpectMsg <InsertResponse>();
        }