docs: clarify in-memory client contracts

This commit is contained in:
2026-07-22 21:01:03 +08:00
parent 8523b01231
commit 6957feacb6
2 changed files with 8 additions and 5 deletions
+6 -4
View File
@@ -137,10 +137,12 @@ func newClient(options ...ClientOption) (*Client, error) {
}
// WithAuthDataChanged configures synchronous persistence for in-memory auth updates.
// The callback runs under the client's internal login serialization. It must not
// call Client methods other than AuthData or acquire a lock that may be held by any
// goroutine calling Client. Callers must not call Client while holding a lock that
// the callback may acquire. Returning an error leaves authentication unchanged.
// The callback runs under the client's internal login serialization and must not
// use Client directly or indirectly, including by waiting for a goroutine, future,
// channel, or hook whose completion may call Client. It should perform only bounded,
// standalone persistence and return. The callback and Client callers must obey lock
// ordering: neither may hold a lock needed by the other. Returning an error leaves
// authentication unchanged.
func WithAuthDataChanged(callback func(AuthData) error) ClientOption {
return func(client *Client) error {
if callback == nil {