MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / ackWorker

Method ackWorker

client/conn.go:171–207  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

169}
170
171func (c *pconn) ackWorker() {
172 defer c.wg.Done()
173
174 var (
175 oneTime sync.Once
176 pc rpc.PCaller
177 err error
178 )
179
180ackWorkerLoop:
181 for {
182 ack, got := <-c.ackCh
183 if !got { // closed and empty
184 break ackWorkerLoop
185 }
186 oneTime.Do(func() {
187 pc = c.pCaller.New()
188 })
189 if err = ack.Sign(c.parent.privKey); err != nil {
190 log.WithField("target", pc.Target()).WithError(err).Error("failed to sign ack")
191 continue
192 }
193
194 var ackRes types.AckResponse
195 // send ack back
196 if err = pc.Call(route.DBSAck.String(), ack, &ackRes); err != nil {
197 log.WithError(err).Debug("send ack failed")
198 continue
199 }
200 }
201
202 if pc != nil {
203 pc.Close()
204 }
205
206 log.Debug("ack worker quiting")
207}
208
209func (c *pconn) close() error {
210 c.stopAckWorkers()

Callers 1

startAckWorkersMethod · 0.95

Calls 13

WithFieldFunction · 0.92
WithErrorFunction · 0.92
DebugFunction · 0.92
DoMethod · 0.80
ErrorMethod · 0.80
WithErrorMethod · 0.80
DebugMethod · 0.80
NewMethod · 0.65
SignMethod · 0.65
TargetMethod · 0.65
CallMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected