github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/topic/topicreader/batch_options.go (about)

     1  package topicreader
     2  
     3  import "github.com/ydb-platform/ydb-go-sdk/v3/internal/topic/topicreaderinternal"
     4  
     5  // WithBatchMaxCount max messages within batch
     6  type WithBatchMaxCount int
     7  
     8  var _ ReadBatchOption = WithBatchMaxCount(0)
     9  
    10  // Apply implements ReadBatchOption interface
    11  func (count WithBatchMaxCount) Apply(
    12  	options topicreaderinternal.ReadMessageBatchOptions,
    13  ) topicreaderinternal.ReadMessageBatchOptions {
    14  	options.MaxCount = int(count)
    15  
    16  	return options
    17  }
    18  
    19  // WithBatchPreferMinCount set prefer min count for batch size. Sometime result batch can be less then count
    20  // for example if internal buffer full and can't receive more messages or server stop send messages in partition
    21  //
    22  // count must be 1 or greater
    23  // it will panic if count < 1
    24  //
    25  // Deprecated: (was experimental) will be removed soon.
    26  // The option will be removed for simplify code internals
    27  type WithBatchPreferMinCount int
    28  
    29  // Apply implements ReadBatchOption interface
    30  func (count WithBatchPreferMinCount) Apply(
    31  	options topicreaderinternal.ReadMessageBatchOptions,
    32  ) topicreaderinternal.ReadMessageBatchOptions {
    33  	if count < 1 {
    34  		panic("ydb: min batch size must be 1 or greater")
    35  	}
    36  	options.MinCount = int(count)
    37  
    38  	return options
    39  }