-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Client split #525
Client split #525
Conversation
This is cool! I will see if I can get some time over the weekend to try the client-oriented approach which may reduce the total amount of code we need to produce. I like the builder API but I'd also like to see what the least amount of code looks like and then work from there. I am sure deriving default probably nukes any gains here but worth a shot. client.customize().strategy().send(PayInvoice {
..Default::default()
}); The StripeRequest trait is v cool. |
This was on the list of TODO's to add back where possible. Though since the id parameters are now part of the request builder, many fewer request parameters can implement I'm also hopeful that while generating more code is annoying, it won't be much of a maintenance burden since builder methods are straightforward (and does not seem to affect compile time). |
b0676cb
to
3bc8f49
Compare
Think this is at least ready for review. There's plenty to bikeshed on naming, other ergonomics changes, etc., but that can happen either in this pr or in future release candidates / PR's on the next branch.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I think we are very close. A few comments:
- I think we should use the 'async-stripe' prefix for everything. It's wordy but I don't think stripe want us to use 'stripe' directly. It was suggested to me in the past to rename this crate to something else altogether such as
payments
but I am worried about the SEO. - structure: lets put the clients in their own folder. This leaves a good question of how people actually use this project. Perhaps the async-stripe crate should be just a re-export of async_stripe_tokio_hyper or perhaps we should let people pick which re-export they want using features. This is purely for discoverability. I think async-stripe in the root, two clients in the clients folders (perhaps 3 for blocking?), and some re-export mechanism qualifies as 'done' here.
- examples: missing out on the code docs is unfortunate HOWEVER I don't think we even have a choice any longer. Any meaningful examples need a client and that would create a loop against stripe_shared. What we have now is the best option given this.
- I would like to add simple tests that the example binaries all work but that can be independent of this PR
- Is it possible to avoid clients having to define a 'config' builder? Perhaps we can have one that we give to the client to build it. Maybe add a fn to the Client trait that takes a Config and returns Self? stripe_async_std::config::ClientBuilder feels pretty boilerplatey. Not a huge issue since it is a relatively small amount of code
Cool! I updated to v1001 and added the new APIs to the mapping. We could maybe do some smart stuff around following dependencies but I will also leave that for another PR. Example:
In this chain, since |
Sounds good, will do. Separate from the crate names, are we allowed to do the
My main thinking here was just that the I'll look into allowing a root
Right now in the CI there is the step
Config is definitely boilerplatey. My main thoughts around the current iteration of config handling were to keep it more of a simple proof of concept, since I expect it will change and be improved/extended over time. My main thinking in keeping configs separate and not tied to the trait were solely around making the clients as minimally coupled as possible (and ensuring the Client trait does not need to depend on deps like For example, we might want config pieces that are unique to the specific client, e.g.
|
I think this is ok, but only becuase I've not been advised anything else. I think they just don't want the cargo crate name clashing.
I agree that the feature flagging is annoying but if it's simply an optional dependency and a crate re-export we should be ok. I think really this should be a backwards compat / convenience thing mainly. The main thing is that the rest of the library (all the types) are no longer tied to the client type so this feature flag as far less far-reaching implications.
Compiling is good, running them is better. Not sure what the best option for this is though and I am happy to defer that.
Ok, lets leave it. |
f34bf78
to
fd94ab2
Compare
Done in 4efa17a
Done in c9369a2 (for now also just consolidated the previous Feature flag names + interactions could definitely be debated + improved, but think this is a good starting point since lots of future changes will affect this anyway (e.g. flags for supporting both hyper <1, >= 1, better reexporting of the generated types / requests / etc.) |
Nice work! Is there a checklist anywhere with what's left (ie remaining work)? |
On my end, main items I expect are
FWIW, I've been using the |
Hey, @mzeitlin11 I am ready to merge this into |
@arlyon, ready to merge! |
Built on #452, so most of the diff is that. cc @arlyon, I was messing around with implementing the code generation side of your comment #452 (comment) and just wanted to push this up for early conversation and to make sure no work was being duplicated.
Closes #298, closes #380, closes #463, closes #520, most of #535, allows #274 more easily
Details
The main traits are defined here and primarily match #452 (comment), with one exception being defining our own library-agnostic simple
RequestBuilder
instead of usinghttp-types
. This allows removing that dependency for thehyper
-based client and removing the need for annoying conversions.One other cool benefit here is the ability to use
.customize
on anyRequestBuilder
, to receive aCustomizableRequestBuilder
capable of setting per-request configuration (for example, to solve (#520, #380)).Beyond this file, most of the work is modifying the code generation to produce this
RequestBuilder
. Part of making the request structs implementStripeRequest
required converting to more of a builder pattern (see the example changes below).Examples
Previous
New
Customization Example