/// <summary>
        /// Bridge classification of single operation's argument.
        /// Get the argument data and pass it to the segmentation strategies.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strategy">The strategy.</param>
        /// <param name="options">The options.</param>
        /// <param name="operation">The operation.</param>
        /// <param name="argumentName">Name of the argument.</param>
        /// <param name="producedData">The produced data.</param>
        /// <returns></returns>
        private async ValueTask <Bucket> ClassifyArgumentAsync <T>(
            IProducerAsyncSegmentationStrategy strategy,
            IEventSourceOptions options,
            string operation,
            string argumentName,
            T producedData)
        {
            Bucket segments = Bucket.Empty;

            var seg = await strategy.TryClassifyAsync(
                segments,
                operation,
                argumentName,
                producedData,
                options);

            #region Validation

            if (seg == null)
            {
                return(segments);
            }

            #endregion // Validation

            return(seg);
        }
 /// <summary>
 /// Try to classifies instance into different segments.
 /// Segments is how the producer sending its raw data to
 /// the consumer. It's in a form of dictionary when
 /// keys represent the different segments
 /// and the value represent serialized form of the segment's data.
 /// EXPECTED to return the segments argument if it not responsible of
 /// specific parameter handling.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="segments">The segments which was collect so far.
 /// It start as Empty and flow though all the registered segmentation strategies.</param>
 /// <param name="operation">The operation's key which represent the method call at the
 /// producer proxy.
 /// This way you can segment same type into different slot.</param>
 /// <param name="argumentName">Name of the argument.</param>
 /// <param name="producedData">The produced data.</param>
 /// <param name="options">The options.</param>
 /// <returns>
 /// bytes for each segment or
 /// the segments argument if don't responsible for segmentation of the type.
 /// </returns>
 /// <example>
 /// Examples for segments can be driven from regulation like
 /// GDPR (personal, non-personal data),
 /// Technical vs Business aspects, etc.
 /// </example>
 ValueTask <Bucket> IProducerAsyncSegmentationStrategy.TryClassifyAsync <T>(
     Bucket segments,
     string operation,
     string argumentName,
     T producedData,
     IEventSourceOptions options)
 {
     return(_sync.Classify(segments, operation, argumentName, producedData, options).ToValueTask());
 }
Esempio n. 3
0
        ValueTask <Bucket> IProducerAsyncSegmentationStrategy.
        TryClassifyAsync <T>(
            Bucket segments,
            string operation,
            string argumentName,
            T producedData,
            IEventSourceOptions options)
        {
            ReadOnlyMemory <byte> data = options.Serializer.Serialize(producedData);
            string key = $"{PREFIX}~{operation}~{argumentName}";

            return(segments.Add(key, data).ToValueTask());
        }
Esempio n. 4
0
 /// <summary>
 /// Withes the options.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <returns></returns>
 public ProducerPlan WithOptions(
     IEventSourceOptions options)
 {
     return(new ProducerPlan(this, options: options));
 }
        /// <summary>
        /// Apply configuration.
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        IProducerPartitionBuilder IProducerOptionsBuilder.WithOptions(IEventSourceOptions options)
        {
            var prms = Plan.WithOptions(options);

            return(new ProducerBuilder(prms));
        }