public static void InvokeDistrubited(Keys k) { if (Distributed != null) { Distributed.Invoke(k); } }
public IEnumerable <Action <Distributed <TMessage> > > Enumerate(Distributed <TMessage> item) { if (!_worker.CanAcceptMessage(item)) { yield break; } RewriteResponseAddress(item.ResponseAddress); foreach (var sinkAction in _sink.Enumerate(item.Payload)) { Action <TMessage> action = sinkAction; yield return(message => { _worker.IncrementInProgress(); try { _worker.ConsumingMessage(message); action(message.Payload); } finally { _worker.DecrementInProgress(); } }); } }
public void Consume(Distributed <T> message) { _pendingMessages.Consumed(message.CorrelationId); Action <T> consumer = _getConsumer(message.Payload); Interlocked.Increment(ref _inProgress); try { RewriteResponseAddress(message.ResponseAddress); consumer(message.Payload); } finally { Interlocked.Decrement(ref _inProgress); ScheduleUpdate(); ScheduleWakeUp(); var disposal = consumer as IDisposable; if (disposal != null) { disposal.Dispose(); } } }
public void Consume(Distributed <TMessage> message) { _pendingMessages.Consumed(message.CorrelationId); Action <TMessage> consumer = _getConsumer(message.Payload); Interlocked.Increment(ref _inProgress); try { RewriteResponseAddress(message.ResponseAddress); consumer(message.Payload); var consumeContext = _bus.MessageContext <Distributed <TMessage> >(); consumeContext.BaseContext.NotifyConsume(consumeContext, typeof(Worker <TMessage>).ToShortTypeName(), message.CorrelationId.ToString()); } finally { Interlocked.Decrement(ref _inProgress); ScheduleUpdate(); ScheduleWakeUp(); var disposal = consumer as IDisposable; if (disposal != null) { disposal.Dispose(); } } }
public bool Accept(Distributed <T> message) { if (_inProgress >= _inProgressLimit) { _pendingMessages.Viewed(message.CorrelationId); return(false); } return(true); }
public DistributedProfilingContext() { m_clients = new IClient[] { new Client <ClientConnection>(new ConnectionOptions("Port=11211"), ClientConnection.CreateFactory, ClientConnection.ReleaseFactory), new Client <ClientConnection>(new ConnectionOptions("Port=11311"), ClientConnection.CreateFactory, ClientConnection.ReleaseFactory) }; var distributed = new Distributed(new DistributedOptions(), new HashAlgorithmProvider <FNV32ModifiedHashAlgorithm>()); distributed.AddRange(m_clients); Distributed = distributed; }
public void Consume(T message) { WorkerDetails worker = _selectionStrategy.GetAvailableWorkers(_workers.Values, message, false).FirstOrDefault(); if (worker == null) { CurrentMessage.RetryLater(); return; } worker.Add(); IEndpoint endpoint = _endpointFactory.GetEndpoint(worker.DataUri); var distributed = new Distributed <T>(message, CurrentMessage.Headers.ResponseAddress); endpoint.Send(distributed); }
public override int GetHashCode() { if (Attribute == null && Id == null) { return(31 * Distributed.GetHashCode()); } if (Attribute == null) { return(31 * Distributed.GetHashCode() + Id !.GetHashCode()); } if (Id == null) { return(31 * Attribute.GetHashCode() + Distributed.GetHashCode()); } return(31 * Attribute.GetHashCode() + Distributed.GetHashCode() + Id.GetHashCode()); }
private IEnumerator AddingCards(int count) { IsDistributing = true; yield return(StartCoroutine(RegivingCards())); for (int i = 0; i < count; i++) { Card newCard = Instantiate(_cardPrefab, _cardGrid.transform); newCard.ImageTransform.position = transform.position; _cards.Add(newCard); yield return(StartCoroutine(MoveCardToCell(newCard))); Distributed?.Invoke(newCard); } SeedCards(); yield return(StartCoroutine(ScaleCards())); IsDistributing = false; }
public void Consume(TMessage message) { WorkerDetails worker; lock (_workers) { worker = _selectionStrategy.SelectWorker(_workers.Values, message); if (worker == null) { _bus.MessageContext <TMessage>().RetryLater(); return; } worker.Add(); } IEndpoint endpoint = _bus.GetEndpoint(worker.DataUri); var distributed = new Distributed <TMessage>(message, _bus.Context().ResponseAddress); endpoint.Send(distributed); }
IEnumerable <Action <IConsumeContext <TMessage> > > Handle(IWorkerInfo <TMessage> worker) { yield return(context => { context.BaseContext.NotifyConsume(context, typeof(DistributorMessageSink <TMessage>).ToShortTypeName(), null); IEndpoint endpoint = context.Bus.GetEndpoint(worker.DataUri); if (_log.IsDebugEnabled) { _log.DebugFormat("Sending {0}[{1}] to {2}", typeof(TMessage).ToShortTypeName(), context.MessageId, worker.DataUri); } var distributed = new Distributed <TMessage>(context.Message, context.ResponseAddress); endpoint.Send(distributed, x => { x.SetRequestId(context.RequestId); x.SetConversationId(context.ConversationId); x.SetCorrelationId(context.CorrelationId); x.SetSourceAddress(context.SourceAddress); x.SetDestinationAddress(context.DestinationAddress); x.SetResponseAddress(context.ResponseAddress); x.SetFaultAddress(context.FaultAddress); x.SetNetwork(context.Network); if (context.ExpirationTime.HasValue) { x.SetExpirationTime(context.ExpirationTime.Value); } context.Headers.Each(header => x.SetHeader(header.Key, header.Value)); x.SetHeader("mt.worker.uri", worker.DataUri.ToString()); }); }); }
public void ConsumingMessage <TMessage>(Distributed <TMessage> message) { _pendingMessages.Consumed(message.CorrelationId); }
public override int GetHashCode() => 31 *Attribute.GetHashCode() + Distributed.GetHashCode() + Id.GetHashCode();