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

Method Start

pkg/proxy/session.go:114–150  ·  view source on GitHub ↗
(d *Router)

Source from the content-addressed store, hash-verified

112var RespOK = redis.NewString([]byte("OK"))
113
114func (s *Session) Start(d *Router) {
115 s.start.Do(func() {
116 if int(incrSessions()) > s.config.ProxyMaxClients {
117 go func() {
118 s.Conn.Encode(redis.NewErrorf("ERR max number of clients reached"), true)
119 s.CloseWithError(ErrTooManySessions)
120 s.incrOpFails(nil, nil)
121 s.flushOpStats(true)
122 }()
123 decrSessions()
124 return
125 }
126
127 if !d.isOnline() {
128 go func() {
129 s.Conn.Encode(redis.NewErrorf("ERR router is not online"), true)
130 s.CloseWithError(ErrRouterNotOnline)
131 s.incrOpFails(nil, nil)
132 s.flushOpStats(true)
133 }()
134 decrSessions()
135 return
136 }
137
138 tasks := NewRequestChanBuffer(1024)
139
140 go func() {
141 s.loopWriter(tasks)
142 decrSessions()
143 }()
144
145 go func() {
146 s.loopReader(tasks, d)
147 tasks.Close()
148 }()
149 })
150}
151
152func (s *Session) loopReader(tasks *RequestChan, d *Router) (err error) {
153 defer func() {

Callers

nothing calls this directly

Calls 12

CloseWithErrorMethod · 0.95
incrOpFailsMethod · 0.95
flushOpStatsMethod · 0.95
loopWriterMethod · 0.95
loopReaderMethod · 0.95
incrSessionsFunction · 0.85
decrSessionsFunction · 0.85
NewRequestChanBufferFunction · 0.85
isOnlineMethod · 0.80
CloseMethod · 0.65
DoMethod · 0.45
EncodeMethod · 0.45

Tested by

no test coverage detected