Exemplo n.º 1
0
        public EventsByTagActor(EventsByTag <T> message, IActorRef client, IActorRef lookup, IActorRef cnxPool, IActorRef generator, ISchema <T> schema)
        {
            _admin     = new Admin.Public.Admin(message.AdminUrl, new HttpClient());
            _message   = message;
            _schema    = schema;
            _client    = client;
            _cnxPool   = cnxPool;
            _lookup    = lookup;
            _generator = generator;
            _buffer    = new BufferBlock <IMessage <T> >();
            var topic      = $"persistent://{message.Tenant}/{message.Namespace}/{message.Topic}";
            var partitions = _admin.GetPartitionedMetadata(message.Tenant, message.Namespace, message.Topic);

            Setup(partitions.Body, topic);

            Receive <ReceivedMessage <T> >(m =>
            {
                _buffer.Post(m.Message);
            });
            Receive <Messages.Receive>(_ =>
            {
                if (_buffer.TryReceive(out var message))
                {
                    Sender.Tell(new AskResponse(message));
                }
                else
                {
                    Sender.Tell(new AskResponse(null));
                }
            });
        }
Exemplo n.º 2
0
        public EventsByTagActor(EventsByTag message, BufferBlock <IEventEnvelope> buffer)
        {
            _admin   = new Admin.Public.Admin(message.AdminUrl, new HttpClient());
            _message = message;
            _buffer  = buffer;
            var topic      = $"persistent://{message.Tenant}/{message.Namespace}/{message.Topic}";
            var partitions = _admin.GetPartitionedMetadata(message.Tenant, message.Namespace, message.Topic, true);

            Setup(partitions.Body);
        }
Exemplo n.º 3
0
        public ReaderSource <T> TaggedEvents(Tag tag)
        {
            if (tag == null)
            {
                throw new ArgumentException("Tag is null");
            }

            var actorName = Regex.Replace(_topic, @"[^\w\d]", "");
            var msg       = new EventsByTag <T>(_tenant, _namespace, _topic, _fromMessageId, _toMessageId, tag, _brokerWebServiceUrl, _conf.ReaderConfigurationData, _clientConfiguration);
            var actor     = _actorSystem.ActorOf(EventsByTagActor <T> .Prop(msg, _client, _lookup, _cnxPool, _generator, _schema), actorName);

            return(new ReaderSource <T>(_brokerWebServiceUrl, actor));
        }
Exemplo n.º 4
0
        public SqlSource <IEventEnvelope> TaggedEvents(Tag tag)
        {
            if (tag == null)
            {
                throw new ArgumentException("Tag is null");
            }

            var buffer    = new BufferBlock <IEventEnvelope>();
            var actorName = Regex.Replace(_topic, @"[^\w\d]", "");
            var msg       = new EventsByTag(_tenant, _namespace, _topic, _selectedColumns, _fromMessageId, _toMessageId, tag, _options, _brokerWebServiceUrl);
            var actor     = _actorSystem.ActorOf(EventsByTagActor.Prop(msg, buffer), actorName);

            return(new SqlSource <IEventEnvelope>(_brokerWebServiceUrl, buffer, actor));
        }
Exemplo n.º 5
0
 public static Props Prop(EventsByTag <T> message, IActorRef client, IActorRef lookup, IActorRef cnxPool, IActorRef generator, ISchema <T> schema)
 {
     return(Props.Create(() => new EventsByTagActor <T>(message, client, lookup, cnxPool, generator, schema)));
 }
Exemplo n.º 6
0
 public static Props Prop(EventsByTag message, BufferBlock <IEventEnvelope> buffer)
 {
     return(Props.Create(() => new EventsByTagActor(message, buffer)));
 }