-
Notifications
You must be signed in to change notification settings - Fork 104
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
Reorder context, future-proof for a tracing context world #89
Comments
Holding for now -- seems we should gather a wider consensus and then commit and go all in with all libs we control. |
I'm just copy & pasting my arguments from the AsyncHTTPClient PR comments: Swift has many APIs that read like
More importantly, you're only supposed to add the "Observer" bit when you're "compensating for weak type information". So in many APIs where it's much clearer, you're supposed to just name the method Example:
Basically, you cannot just skip over |
I think here we should follow the convention of other Lambda frameworks.
In addition, I also suggest to change In my opinion we need to simplify the learning curve by adopting common usage pattern used in other languages. |
@ktoso do you agree we should do last now? Or need more data? |
Some more data: in gRPC Swift we follow the context-last-except-for-trailing-closures rule: In server RPC handlers where users implement the service logic:
These contexts vary by the RPC type but broadly provide things like the event loop and ways to send messages as well as a logger. For client RPCs:
These are all “CallOptions” (i.e. timeout/deadline, encoding, metadata), more or less a context. |
Yes I've collected info from various libs (including gRPC) and run it by Kyle (stdlib) and seems we're converging on that. Still need to sanity check with some folks before it's "the official stance of the swift team" or whatnot, but that'll happen after wwdc. The specific rule we arrived at is a bit more detailed, as takes into account defaulted parameters etc, and it seems to be:
|
In light of https://github.com/swift-server/async-http-client/pull/227/files#r429299831 and a number of long discussions and pondering about this...
I think we'll get the best APIs and outcome for all server libs if we stick to one style, and the "context last" indeed has some gains in Swift... I can go in depth about what convinced me today after hours of chatting with Johannes and looking at my own APIs.
This proposes to reshape the API to become:
and we'd encourage the same shape in APIs I work on myself, AsyncHTTPClient, and the Baggage / Context work that's ongoing with GSoC/Moritz. (Swift gRPC already fits).
(Pretty sure people have strong feelings about this so we can talk it over?)
Specific rule wise I think we'd end up with:
Believe me, it took a lot of convincing for me to change my mind... As long as we end up on the same style there will be great benefits for consistency of looks of server swift code though.
The text was updated successfully, but these errors were encountered: