private IPartitionSelectorStrategy GetPartitionSelectorStrategy(IProducerOptions options)
        {
            IPartitionSelectorStrategy strategy = null;

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

                if (_selectors.Count() == 1)
                {
                    strategy = _selectors.Single();
                }
                else
                {
                    strategy = new DefaultPartitionSelector();
                }
            }

            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);
 }