MCPcopy
hub / github.com/aceld/zinx / Start

Method Start

znet/connection.go:296–329  ·  view source on GitHub ↗

Start starts the connection and makes the current connection work. (启动连接,让当前连接开始工作)

()

Source from the content-addressed store, hash-verified

294// Start starts the connection and makes the current connection work.
295// (启动连接,让当前连接开始工作)
296func (c *Connection) Start() {
297 defer func() {
298 if err := recover(); err != nil {
299 zlog.Ins().ErrorF("Connection Start() error: %v", err)
300 }
301 }()
302 c.ctx, c.cancel = context.WithCancel(context.Background())
303
304 // Execute the hook method for processing business logic when creating a connection
305 // (按照用户传递进来的创建连接时需要处理的业务,执行钩子方法)
306 c.callOnConnStart()
307
308 // Start heartbeating detection
309 if c.hc != nil {
310 c.hc.Start()
311 c.updateActivity()
312 }
313
314 // 占用workerid
315 c.workerID = useWorker(c)
316
317 // Start the Goroutine for reading data from the client
318 // (开启用户从客户端读取数据流程的Goroutine)
319 go c.StartReader()
320
321 select {
322 case <-c.ctx.Done():
323 c.finalizer()
324
325 // 归还workerid
326 freeWorker(c)
327 return
328 }
329}
330
331// Stop stops the connection and ends the current connection state.
332// (停止连接,结束当前连接状态)

Callers

nothing calls this directly

Calls 9

callOnConnStartMethod · 0.95
updateActivityMethod · 0.95
StartReaderMethod · 0.95
finalizerMethod · 0.95
InsFunction · 0.92
useWorkerFunction · 0.85
freeWorkerFunction · 0.85
ErrorFMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected