MCPcopy Index your code
hub / github.com/coder/coder / WrapAgentConn

Function WrapAgentConn

codersdk/workspacesdk/agentconn.go:52–63  ·  view source on GitHub ↗

WrapAgentConn returns an AgentConn that delegates every operation to conn and applies closeFunc exactly once when the logical session is closed. If conn is nil, any provided closeFunc is invoked immediately so logical session cleanup is not silently dropped.

(conn AgentConn, closeFunc func() error)

Source from the content-addressed store, hash-verified

50// If conn is nil, any provided closeFunc is invoked immediately so logical
51// session cleanup is not silently dropped.
52func WrapAgentConn(conn AgentConn, closeFunc func() error) AgentConn {
53 if conn == nil {
54 if closeFunc != nil {
55 _ = closeFunc()
56 }
57 return nil
58 }
59 if closeFunc == nil {
60 closeFunc = func() error { return nil }
61 }
62 return &wrappedAgentConn{AgentConn: conn, closeFunc: closeFunc}
63}
64
65type wrappedAgentConn struct {
66 AgentConn

Callers 1

openAgentConnFunction · 0.92

Calls 1

closeFuncFuncType · 0.50

Tested by

no test coverage detected