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

implement clone derive macro for Sivx client #777

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

imabdulbasit
Copy link

Motivation

Configuration struct derives clone macro so Sivx struct can also derive it. This would be helpful to clone Sivx client when sharing it between threads without wrapping it in Arc.

Solution

Add Clone derive macro

@tasn
Copy link
Member

tasn commented Jan 20, 2023

I'm not against cloning it per-se, but it feels wasteful to clone it and all of the inner structure for it. I almost feel like if you want to do it, we should at least have the inner object wrapped in an Arc, no?

@imabdulbasit
Copy link
Author

imabdulbasit commented Jan 20, 2023

I'm not against cloning it per-se, but it feels wasteful to clone it and all of the inner structure for it. I almost feel like if you want to do it, we should at least have the inner object wrapped in an Arc, no?

Inner structure already has Clone implemented. Svix client uses reqwest which implements Arc internally :)

@tasn
Copy link
Member

tasn commented Jan 22, 2023

There's a Configuration structure, no? It probably includes multiple things in it.

@imabdulbasit
Copy link
Author

imabdulbasit commented Jan 30, 2023

There's a Configuration structure, no? It probably includes multiple things in it.

Yes but Configuration structure already implements Clone (https://docs.rs/webhooks/0.0.1/src/webhooks/apis/configuration.rs.html#14) so Svix struct can also implement clone

@tasn
Copy link
Member

tasn commented Jan 30, 2023

Yeah, but that's what I'm saying, it ends up cloning the whole Configuration structure...

Anyhow, I can go either way. @svix-gabriel, do you have any thoughts on this?

@svix-gabriel
Copy link
Contributor

I definitely see the value in implementing Clone, but I agree with the suggestion that this should wrap the Configuration struct in an Arc<...> internally. Clone will be more performant if it's just incrementing a reference count, rather than copying all of the underlying strings and other configuration data.

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.

None yet

3 participants