MCPcopy
hub / github.com/redis/go-redis / Close

Method Close

redis.go:1090–1116  ·  view source on GitHub ↗

Close closes the client, releasing any open resources. It is rare to Close a Client, as the Client is meant to be long-lived and shared between many goroutines.

()

Source from the content-addressed store, hash-verified

1088// It is rare to Close a Client, as the Client is meant to be
1089// long-lived and shared between many goroutines.
1090func (c *baseClient) Close() error {
1091 var firstErr error
1092
1093 // Close maintnotifications manager first
1094 if err := c.disableMaintNotificationsUpgrades(); err != nil {
1095 firstErr = err
1096 }
1097
1098 if err := c.onClose.run(); err != nil && firstErr == nil {
1099 firstErr = err
1100 }
1101
1102 // Unregister pools from OTel before closing them
1103 otel.UnregisterPools(c.connPool, c.pubSubPool)
1104
1105 if c.connPool != nil {
1106 if err := c.connPool.Close(); err != nil && firstErr == nil {
1107 firstErr = err
1108 }
1109 }
1110 if c.pubSubPool != nil {
1111 if err := c.pubSubPool.Close(); err != nil && firstErr == nil {
1112 firstErr = err
1113 }
1114 }
1115 return firstErr
1116}
1117
1118func (c *baseClient) getAddr() string {
1119 return c.opt.Addr

Calls 4

UnregisterPoolsFunction · 0.92
runMethod · 0.80
CloseMethod · 0.65

Tested by 1