private static ConsumerExecutorDescriptor InitDescriptor(
            TopicAttribute attr,
            MethodInfo methodInfo,
            TypeInfo implType)
        {
            var descriptor = new ConsumerExecutorDescriptor
            {
                Attribute    = attr,
                MethodInfo   = methodInfo,
                ImplTypeInfo = implType
            };

            return(descriptor);
        }
Beispiel #2
0
        /// <summary>
        /// Attempts to get the topic executor associated with the specified topic name and group name from the
        /// <see cref="Entries" />.
        /// </summary>
        /// <param name="topicName">The topic name of the value to get.</param>
        /// <param name="groupName">The group name of the value to get.</param>
        /// <param name="matchTopic">topic executor of the value.</param>
        /// <returns>true if the key was found, otherwise false. </returns>
        public bool TryGetTopicExecutor(string topicName, string groupName,
                                        out ConsumerExecutorDescriptor matchTopic)
        {
            if (Entries == null)
            {
                throw new ArgumentNullException(nameof(Entries));
            }

            matchTopic = null;

            if (Entries.TryGetValue(groupName, out var groupMatchTopics))
            {
                matchTopic = _selector.SelectBestCandidate(topicName, groupMatchTopics);

                return(matchTopic != null);
            }

            return(false);
        }
Beispiel #3
0
 /// <summary>
 /// create a new instance of  <see cref="ConsumerContext" /> .
 /// </summary>
 /// <param name="descriptor">consumer method descriptor. </param>
 /// <param name="message"> received message.</param>
 public ConsumerContext(ConsumerExecutorDescriptor descriptor, MessageContext message)
 {
     ConsumerDescriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor));
     DeliverMessage     = message ?? throw new ArgumentNullException(nameof(message));
 }