Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify functions should check if the client is closed #248

Open
Zerpet opened this issue Oct 25, 2023 · 1 comment
Open

Notify functions should check if the client is closed #248

Zerpet opened this issue Oct 25, 2023 · 1 comment
Labels
v2.x Applicable to v2.x issues
Milestone

Comments

@Zerpet
Copy link
Contributor

Zerpet commented Oct 25, 2023

func (tc *Client) NotifyPublishError() <-chan *PublishError {
tc.mu.Lock()
defer tc.mu.Unlock()
p := make(chan *PublishError, 1)
tc.publishErrorCh = p
return p
}

These functions could check that the client is not closed, nor closing. We could change the signature to return a channel and an error, and return a specific error when the client is not open.

@Zerpet Zerpet added the v2.x Applicable to v2.x issues label Oct 25, 2023
@Zerpet Zerpet added this to the 2.0 milestone Oct 25, 2023
@Zerpet
Copy link
Contributor Author

Zerpet commented Oct 25, 2023

I'm undecided if it's needed, other than for correctness. I came up with this when I was thinking about the idempotency of raw.Client.Close() and Client.shutdown(). Given that all notify and shutdown function synchronise, this may not be needed at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2.x Applicable to v2.x issues
Projects
None yet
Development

No branches or pull requests

1 participant