MCPcopy
hub / github.com/CodisLabs/codis / serveProxy

Method serveProxy

pkg/proxy/proxy.go:396–428  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

394}
395
396func (s *Proxy) serveProxy() {
397 if s.IsClosed() {
398 return
399 }
400 defer s.Close()
401
402 log.Warnf("[%p] proxy start service on %s", s, s.lproxy.Addr())
403
404 eh := make(chan error, 1)
405 go func(l net.Listener) (err error) {
406 defer func() {
407 eh <- err
408 }()
409 for {
410 c, err := s.acceptConn(l)
411 if err != nil {
412 return err
413 }
414 NewSession(c, s.config).Start(s.router)
415 }
416 }(s.lproxy)
417
418 if d := s.config.BackendPingPeriod.Duration(); d != 0 {
419 go s.keepAlive(d)
420 }
421
422 select {
423 case <-s.exit.C:
424 log.Warnf("[%p] proxy shutdown", s)
425 case err := <-eh:
426 log.ErrorErrorf(err, "[%p] proxy exit on error", s)
427 }
428}
429
430func (s *Proxy) keepAlive(d time.Duration) {
431 var ticker = time.NewTicker(math2.MaxDuration(d, time.Second))

Callers 1

NewFunction · 0.95

Calls 10

IsClosedMethod · 0.95
CloseMethod · 0.95
acceptConnMethod · 0.95
keepAliveMethod · 0.95
NewSessionFunction · 0.85
WarnfMethod · 0.80
DurationMethod · 0.80
ErrorErrorfMethod · 0.80
AddrMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected