示例#1
0
 internal void CreateSequenceStores(int count)
 {
     for (int i = 0; i < count; i++)
     {
         if (SequenceStores.Count <= i)
         {
             SequenceStores.Add(ServiceProvider.GetRequiredService <ISequenceStore>());
         }
     }
 }
示例#2
0
        /// <summary>
        ///     Returns the <see cref="ISequenceStore" /> to be used to store the pending sequences.
        /// </summary>
        /// <param name="offset">
        ///     The offset may determine which store is being used. For example a dedicated sequence store is used per
        ///     each Kafka partition, since they may be processed concurrently.
        /// </param>
        /// <returns>
        ///     The <see cref="ISequenceStore" />.
        /// </returns>
        protected virtual ISequenceStore GetSequenceStore(IOffset offset)
        {
            if (SequenceStores.Count == 0)
            {
                lock (SequenceStores)
                    SequenceStores.Add(ServiceProvider.GetRequiredService <ISequenceStore>());
            }

            return(SequenceStores.FirstOrDefault() ??
                   throw new InvalidOperationException("The sequence store is not initialized."));
        }