File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,9 @@ func (a *awsInstance) start() {
148
148
go func () {
149
149
a .logDebug ("discovery job starting" )
150
150
151
+ discoveryTimer := time .NewTimer (a .timeout )
152
+ defer discoveryTimer .Stop ()
153
+
151
154
for {
152
155
select {
153
156
case _ , ok := <- a .update :
@@ -166,7 +169,7 @@ func (a *awsInstance) start() {
166
169
if err != nil {
167
170
a .stop ()
168
171
}
169
- case <- time . After ( a . timeout ) :
172
+ case <- discoveryTimer . C :
170
173
a .logDebug ("discovery job update triggered" )
171
174
172
175
var api * ec2.Client
@@ -192,6 +195,7 @@ func (a *awsInstance) start() {
192
195
}
193
196
194
197
a .logDebug ("discovery job reconciliation completed" )
198
+ discoveryTimer .Reset (a .timeout )
195
199
case <- a .ctx .Done ():
196
200
a .stop ()
197
201
}
Original file line number Diff line number Diff line change @@ -86,6 +86,9 @@ func (c *consulInstance) setAPIClient() error {
86
86
}
87
87
88
88
func (c * consulInstance ) watch () {
89
+ watchTimer := time .NewTimer (c .timeout )
90
+ defer watchTimer .Stop ()
91
+
89
92
for {
90
93
select {
91
94
case _ , ok := <- c .update :
@@ -112,13 +115,14 @@ func (c *consulInstance) watch() {
112
115
}
113
116
case <- c .ctx .Done ():
114
117
c .stop ()
115
- case <- time . After ( c . timeout ) :
118
+ case <- watchTimer . C :
116
119
c .logDebug ("discovery job reconciliation started" )
117
120
if err := c .updateServices (); err != nil {
118
121
// c.log.Errorf("error while updating service: %w", err)
119
122
c .stop ()
120
123
}
121
124
c .logDebug ("discovery job reconciliation completed" )
125
+ watchTimer .Reset (c .timeout )
122
126
}
123
127
}
124
128
}
You can’t perform that action at this time.
0 commit comments