Пример #1
0
 public Task <bool> Append(SaveTransport <PrimaryKey> saveTransport)
 {
     return(Task.Run(async() =>
     {
         var wrap = new DataAsyncWrapper <SaveTransport <PrimaryKey>, bool>(saveTransport);
         var writeTask = mpscChannel.WriteAsync(wrap);
         if (!writeTask.IsCompletedSuccessfully)
         {
             await writeTask;
         }
         return await wrap.TaskSource.Task;
     }));
 }
Пример #2
0
 public Task <bool> Append(IFullyEvent <PrimaryKey> fullyEvent, EventBytesTransport bytesTransport, string unique)
 {
     return(Task.Run(async() =>
     {
         var wrap = new AsyncInputEvent <BatchAppendTransport <PrimaryKey>, bool>(new BatchAppendTransport <PrimaryKey>(fullyEvent, bytesTransport, unique));
         var writeTask = mpscChannel.WriteAsync(wrap);
         if (!writeTask.IsCompletedSuccessfully)
         {
             await writeTask;
         }
         return await wrap.TaskSource.Task;
     }));
 }
Пример #3
0
 public Task Append<Input>(string unitName, Commit<Input> commit) where Input : class, new()
 {
     return Task.Run(async () =>
     {
         var wrap = new AsyncInputEvent<AppendInput, bool>(new AppendInput
         {
             UnitName = unitName,
             TransactionId = commit.TransactionId,
             Data = serializer.Serialize(commit.Data),
             Status = commit.Status
         });
         var writeTask = mpscChannel.WriteAsync(wrap);
         if (!writeTask.IsCompletedSuccessfully)
             await writeTask;
         await wrap.TaskSource.Task;
     });
 }
Пример #4
0
        public Task Run()
        {
            Model = Client.PullModel();
            mpscChannel.Config(Model.Connection.Options.CunsumerMaxBatchSize, Model.Connection.Options.CunsumerMaxMillisecondsInterval);
            if (isFirst)
            {
                isFirst = false;
                Model.Model.ExchangeDeclare(Consumer.EventBus.Exchange, "direct", true);
                Model.Model.QueueDeclare(Queue.Queue, true, false, false, null);
                Model.Model.QueueBind(Queue.Queue, Consumer.EventBus.Exchange, Queue.RoutingKey);
            }
            Model.Model.BasicQos(0, Consumer.Config.Qos, false);
            BasicConsumer           = new EventingBasicConsumer(Model.Model);
            BasicConsumer.Received += async(ch, ea) => await mpscChannel.WriteAsync(ea);

            BasicConsumer.ConsumerTag = Model.Model.BasicConsume(Queue.Queue, Consumer.Config.AutoAck, BasicConsumer);
            return(Task.CompletedTask);
        }
Пример #5
0
 public Task <bool> Append <Input>(string unitName, Commit <Input> commit)
 {
     return(Task.Run(async() =>
     {
         var wrap = new DataAsyncWrapper <AppendInput, bool>(new AppendInput
         {
             UnitName = unitName,
             TransactionId = commit.TransactionId,
             Data = serializer.SerializeToString(commit.Data),
             Status = commit.Status
         });
         var writeTask = mpscChannel.WriteAsync(wrap);
         if (!writeTask.IsCompletedSuccessfully)
         {
             await writeTask;
         }
         return await wrap.TaskSource.Task;
     }));
 }