MCPcopy Create free account
hub / github.com/TalkingData/owl / DialCFC

Method DialCFC

proxy/proxy.go:48–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46}
47
48func (proxy *CFCProxy) DialCFC() {
49 var (
50 tempDelay time.Duration
51 err error
52 cfc *tcp.TCPConn
53 reconnect bool
54 )
55
56retry:
57 if reconnect {
58 lg.Error("cfc session is closed, retry.")
59 }
60 cfc, err = proxy.srv.Connect(GlobalConfig.CFCAddr, nil, nil)
61 if err != nil {
62 if tempDelay == 0 {
63 tempDelay = 5 * time.Millisecond
64 } else {
65 tempDelay *= 2
66 }
67 if max := 5 * time.Second; tempDelay > max {
68 tempDelay = max
69 }
70 time.Sleep(tempDelay)
71 reconnect = true
72 goto retry
73 }
74 lg.Info("connect cfc %s successfully.", GlobalConfig.CFCAddr)
75 proxy.cfc = cfc
76 for {
77 if proxy.cfc.IsClosed() {
78 reconnect = true
79 goto retry
80 }
81 time.Sleep(time.Second)
82 }
83}

Callers 1

mainFunction · 0.80

Calls 2

ConnectMethod · 0.80
IsClosedMethod · 0.45

Tested by

no test coverage detected