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

feat(sdk): implement clone on IggyClient #1599

Closed
wants to merge 1 commit into from

Conversation

patrickariel
Copy link

This makes it so that a single client instance can be easily shared between multiple owners.

@hubcio
Copy link
Contributor

hubcio commented Mar 2, 2025

Adding Clone to IggyClient does not provide benefits since the internal mutex / rwlock already handles sharing.

  • IggyClient contains an IggySharedMut<Box<dyn Client>> which already uses Arc<RwLock<T>> internally
  • The client() method already returns a cloned IggySharedMut, giving you the sharing capability without cloning the entire structure
  • The codebase is designed to share the internal mutex-protected client rather than cloning the entire IggyClient structure

And most importantly: we discourage to use single client. Shared client has worse performance than multiple client. If you clone() client, the calls to network will be done on same IggyClient across all clones, and access to it is protected.

BUT: if you really insist on this functionality, we can merge it ;)

@patrickariel
Copy link
Author

Ok, makes sense. Maybe in the future this library can offer a pooled implementation (with deadpool?), to make it more easy/efficient.

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

Successfully merging this pull request may close these issues.

2 participants