File tree Expand file tree Collapse file tree 2 files changed +0
-48
lines changed Expand file tree Collapse file tree 2 files changed +0
-48
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,6 @@ package kafka
2
2
3
3
import (
4
4
"context"
5
- "log"
6
- "os"
7
- "os/signal"
8
- "syscall"
9
5
"time"
10
6
11
7
"github.com/Shopify/sarama"
@@ -70,7 +66,6 @@ func NewConsumer(config *ConsumerConfig) (*Consumer, error) {
70
66
consumerGroup : consumerGroup ,
71
67
topics : config .Topics ,
72
68
}
73
- consumer .handleKeyInterrupt ()
74
69
return consumer , nil
75
70
}
76
71
@@ -98,23 +93,6 @@ func (c *Consumer) SaramaConsumer() *sarama.ConsumerGroup {
98
93
return & c .consumerGroup
99
94
}
100
95
101
- func (c * Consumer ) handleKeyInterrupt () {
102
- // Capture the Ctrl+C signal (interrupt or kill)
103
- sigChan := make (chan os.Signal , 1 )
104
- signal .Notify (sigChan ,
105
- syscall .SIGINT ,
106
- syscall .SIGTERM ,
107
- syscall .SIGQUIT )
108
-
109
- // Elegant exit
110
- go func () {
111
- <- sigChan
112
- log .Println ("Keyboard-Interrupt signal received, cleaning up before closing" )
113
- closeError := c .consumerGroup .Close ()
114
- log .Println (closeError )
115
- }()
116
- }
117
-
118
96
// Close stops the ConsumerGroup and detaches any running sessions. It is required to call
119
97
// this function before the object passes out of scope, as it will otherwise leak memory.
120
98
func (c * Consumer ) Close () error {
Original file line number Diff line number Diff line change 1
1
package kafka
2
2
3
3
import (
4
- "log"
5
- "os"
6
- "os/signal"
7
- "syscall"
8
-
9
4
"github.com/Shopify/sarama"
10
5
"github.com/pkg/errors"
11
6
)
@@ -46,26 +41,5 @@ func NewProducer(config *ProducerConfig) (*Producer, error) {
46
41
}
47
42
48
43
asyncProducer := Producer {producer }
49
- asyncProducer .handleKeyInterrupt ()
50
44
return & asyncProducer , nil
51
45
}
52
-
53
- func (p * Producer ) handleKeyInterrupt () {
54
- // Capture the Ctrl+C signal (interrupt or kill)
55
- sigChan := make (chan os.Signal , 1 )
56
- signal .Notify (sigChan ,
57
- syscall .SIGINT ,
58
- syscall .SIGTERM ,
59
- syscall .SIGQUIT )
60
-
61
- // Elegant exit
62
- go func () {
63
- <- sigChan
64
- // We always log here, special situation
65
- log .Println ("Keyboard-Interrupt signal received." )
66
- err := p .Close ()
67
- if err != nil {
68
- log .Println (err .Error ())
69
- }
70
- }()
71
- }
You can’t perform that action at this time.
0 commit comments