예제 #1
0
        public static IdExtractor ToIdExtractor(this IMessageExtractor self)
        {
            IdExtractor idExtractor = msg =>
            {
                if (self.EntityId(msg) != null)
                {
                    return(Tuple.Create(self.EntityId(msg), self.EntityMessage(msg)));
                }
                //TODO: should we really use tuples?

                return(null);
            };

            return(idExtractor);
        }
예제 #2
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="self">TBD</param>
        /// <returns>TBD</returns>
        public static ExtractEntityId ToExtractEntityId(this IMessageExtractor self)
        {
            ExtractEntityId extractEntityId = msg =>
            {
                if (self.EntityId(msg) != null)
                {
                    return(Tuple.Create(self.EntityId(msg), self.EntityMessage(msg)));
                }
                //TODO: should we really use tuples?

                return(null);
            };

            return(extractEntityId);
        }
예제 #3
0
        /// <summary>
        /// Register a named entity type `ShardRegion` on this node that will run in proxy only mode, i.e.it will
        /// delegate messages to other `ShardRegion` actors on other nodes, but not host any entity actors itself.
        /// The <see cref="Sharding.ShardRegion"/>  actor for this type can later be retrieved with the
        /// <see cref="ShardRegion"/>  method.
        /// </summary>
        /// <param name="typeName">The name of the entity type.</param>
        /// <param name="role">
        /// Specifies that this entity type is located on cluster nodes with a specific role.
        /// If the role is not specified all nodes in the cluster are used.
        /// </param>
        /// <param name="messageExtractor">
        /// Functions to extract the entity id, shard id, and the message to send to the entity from the incoming message.
        /// </param>
        /// <returns>The actor ref of the <see cref="Sharding.ShardRegion"/> that is to be responsible for the shard.</returns>
        public Task <IActorRef> StartProxyAsync(string typeName, string role, IMessageExtractor messageExtractor)
        {
            IdExtractor extractEntityId = msg =>
            {
                var entityId      = messageExtractor.EntityId(msg);
                var entityMessage = messageExtractor.EntityMessage(msg);
                return(Tuple.Create(entityId, entityMessage));
            };

            return(StartProxyAsync(typeName, role, extractEntityId, messageExtractor.ShardId));
        }
예제 #4
0
        /// <summary>
        /// Register a named entity type `ShardRegion` on this node that will run in proxy only mode, i.e.it will
        /// delegate messages to other `ShardRegion` actors on other nodes, but not host any entity actors itself.
        /// The <see cref="Sharding.ShardRegion"/>  actor for this type can later be retrieved with the
        /// <see cref="ShardRegion"/>  method.
        /// </summary>
        /// <param name="typeName">The name of the entity type.</param>
        /// <param name="role">
        /// Specifies that this entity type is located on cluster nodes with a specific role.
        /// If the role is not specified all nodes in the cluster are used.
        /// </param>
        /// <param name="messageExtractor">
        /// Functions to extract the entity id, shard id, and the message to send to the entity from the incoming message.
        /// </param>
        /// <returns>The actor ref of the <see cref="Sharding.ShardRegion"/> that is to be responsible for the shard.</returns>
        public IActorRef StartProxy(string typeName, string role, IMessageExtractor messageExtractor)
        {
            Tuple <EntityId, Msg> extractEntityId(Msg msg)
            {
                var entityId      = messageExtractor.EntityId(msg);
                var entityMessage = messageExtractor.EntityMessage(msg);

                return(Tuple.Create(entityId, entityMessage));
            };

            return(StartProxy(typeName, role, extractEntityId, messageExtractor.ShardId));
        }
예제 #5
0
        public string EntityId(object message)
        {
            if (message is SubscriptionMessage)
            {
                _adapter.Log(LogLevel.InfoLevel, $"SubscriptionMesage id was {((SubscriptionMessage)message).SubscriptionId.Id}");
            }

            _adapter.Log(LogLevel.InfoLevel, $"Getting entity id for type {message.GetType()} from {_messageExtractor.GetType()}");
            var result = _messageExtractor.EntityId(message);

            _adapter.Log(LogLevel.InfoLevel, $"Entity id was {result}");
            return(result);
        }
 public void RouteShardEnvelope()
 {
     _extractor.EntityId(_m1);
     _extractor.EntityMessage(_m1);
     _extractor.ShardId(_m1);
 }