private IPartitionKeyExtractorStrategy GetPartitionKeyExtractorStrategy(IProducerOptions options)
        {
            IPartitionKeyExtractorStrategy strategy = null;

            if (!string.IsNullOrEmpty(options.PartitionKeyExtractorName))
            {
                strategy = _extractors?.FirstOrDefault((s) => s.ServiceName == options.PartitionKeyExtractorName);
                if (strategy == null)
                {
                    throw new InvalidOperationException("PartitionKeyExtractorStrategy bean with the name '" + options.PartitionKeyExtractorName + "' can not be found.");
                }
            }
            else
            {
                if (_extractors?.Count() > 1)
                {
                    throw new InvalidOperationException("Multiple `IPartitionKeyExtractorStrategy` found from service container.");
                }

                if (_extractors?.Count() == 1)
                {
                    strategy = _extractors.Single();
                }
            }

            return(strategy);
        }
예제 #2
0
 public PartitionHandler(
     IApplicationContext applicationContext,
     IProducerOptions options,
     IPartitionKeyExtractorStrategy partitionKeyExtractorStrategy,
     IPartitionSelectorStrategy partitionSelectorStrategy)
 {
     _applicationContext            = applicationContext;
     _producerOptions               = options;
     _partitionKeyExtractorStrategy = partitionKeyExtractorStrategy;
     _partitionSelectorStrategy     = partitionSelectorStrategy;
     PartitionCount = _producerOptions.PartitionCount;
 }
예제 #3
0
 public PartitionHandler(
     IExpressionParser expressionParser,
     IEvaluationContext evaluationContext,
     IProducerOptions options,
     IPartitionKeyExtractorStrategy partitionKeyExtractorStrategy,
     IPartitionSelectorStrategy partitionSelectorStrategy)
 {
     _expressionParser              = expressionParser;
     _evaluationContext             = evaluationContext ?? new StandardEvaluationContext();
     _producerOptions               = options;
     _partitionKeyExtractorStrategy = partitionKeyExtractorStrategy;
     _partitionSelectorStrategy     = partitionSelectorStrategy;
     PartitionCount = _producerOptions.PartitionCount;
 }
 public PartitioningInterceptor(IExpressionParser expressionParser, IEvaluationContext evaluationContext, IBindingOptions bindingOptions, IPartitionKeyExtractorStrategy partitionKeyExtractorStrategy, IPartitionSelectorStrategy partitionSelectorStrategy)
 {
     _bindingOptions    = bindingOptions;
     _expressionParser  = expressionParser;
     _evaluationContext = evaluationContext;
     _partitionHandler  = new PartitionHandler(
         expressionParser,
         evaluationContext,
         _bindingOptions.Producer,
         partitionKeyExtractorStrategy,
         partitionSelectorStrategy);
 }
 public PartitioningInterceptor(IApplicationContext applicationContext, IBindingOptions bindingOptions, IPartitionKeyExtractorStrategy partitionKeyExtractorStrategy, IPartitionSelectorStrategy partitionSelectorStrategy)
 {
     _bindingOptions   = bindingOptions;
     _partitionHandler = new PartitionHandler(
         applicationContext,
         _bindingOptions.Producer,
         partitionKeyExtractorStrategy,
         partitionSelectorStrategy);
 }