-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstream_opts.go
43 lines (37 loc) · 1.09 KB
/
stream_opts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package easykafka
import "github.com/segmentio/kafka-go"
// StreamWithConsumerOptions sets consumer options
func StreamWithConsumerOptions[T any](opts ...ConsumerOption[T]) StreamOption[T] {
return func(s *Stream[T]) (err error) {
s.consumerOptions = opts
return nil
}
}
// StreamWithProducerOptions sets producer options
func StreamWithProducerOptions[T any](opts ...BaseProducerOption) StreamOption[T] {
return func(s *Stream[T]) (err error) {
s.producerOptions = opts
return nil
}
}
// StreamWithLogger sets logger
func StreamWithLogger[T any](logger kafka.Logger) StreamOption[T] {
return func(c *Stream[T]) (err error) {
c.logger = logger
return nil
}
}
// StreamWithErrorLogger sets error logger
func StreamWithErrorLogger[T any](logger kafka.Logger) StreamOption[T] {
return func(c *Stream[T]) (err error) {
c.errorLogger = logger
return nil
}
}
// StreamWithParallelJobs sets parallel jobs count for stream consumer
func StreamWithParallelJobs[T any](parallelJobs uint) StreamOption[T] {
return func(c *Stream[T]) (err error) {
c.parallelJobs = parallelJobs
return nil
}
}