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.
()
| 1088 | // It is rare to Close a Client, as the Client is meant to be |
| 1089 | // long-lived and shared between many goroutines. |
| 1090 | func (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 | |
| 1118 | func (c *baseClient) getAddr() string { |
| 1119 | return c.opt.Addr |