-
Notifications
You must be signed in to change notification settings - Fork 409
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
Add std::net::http::schedule_request
function
#7831
Conversation
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.
Looks good!
edb/lib/net.edgeql
Outdated
named only headers: optional std::array<std::tuple<name: std::str, value: std::str>>, | ||
) -> std::int16 | ||
named only body: optional std::bytes = <std::bytes>{}, | ||
named only method: optional std::net::http::Method = std::net::http::Method.`GET`, |
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.
I don't quite understand how an optional method
worked inserting into a required property method
🤔
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.
I assume having a default here means the inferred cardinality for this argument is one
?
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.
Is GET a keyword? I assume since it's a default people won't have to mess with it often
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.
Yeah, GET
and DELETE
are keywords and need to be escaped.
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.
We can add other functions for the common HTTP methods, if we want! Might make sense to use that to enforce, for instance, GET and DELETE not having body
is practical usage, for example.
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.
If I set method := <std::net::http::Method>{}
, I get:
edgedb error: MissingRequiredError: missing value for required property 'method' of object type 'std::net::http::ScheduledRequest'
I think this is a compiler issue that allowed AT_MOST_ONE passed to ONE in functions 🤔
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.
Interesting! What is the type of a missing argument if not empty set 😅 . I didn't realize we had an undefined-like type.
I needed to make these are optional
in order to not pass them, or maybe I messed up the function declaration somewhere? I'll play around with it to see if I can understand it better.
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 I figured it out: optional arguments need a default {}
otherwise you get a "function does not exist" error. When I got that error before, I thought it was because any argument that has a default needed optional
in order to be found if you don't pass that argument. I think I'm still a little surprised that = {}
is the way you make an argument optional and optional
is the way you affect the cardinality of the argument type itself, but now that I know it, I think I understand it a little better.
Does `optional` allow passing in an empty set explicitly?
Scott Trinh ***@***.***>于2024年10月4日 周五下午1:58写道:
… ***@***.**** commented on this pull request.
------------------------------
In edb/lib/net.edgeql
<#7831 (comment)>:
> @@ -71,12 +71,21 @@ ALTER TYPE std::net::http::Response {
CREATE FUNCTION
std::net::http::schedule_request(
url: str,
- named only body: optional std::bytes,
- named only method: std::net::http::Method = std::net::http::Method.`GET`,
- named only headers: optional std::array<std::tuple<name: std::str, value: std::str>>,
-) -> std::int16
+ named only body: optional std::bytes = <std::bytes>{},
+ named only method: optional std::net::http::Method = std::net::http::Method.`GET`,
I assume having a default here means the inferred cardinality for this
argument is one?
—
Reply to this email directly, view it on GitHub
<#7831 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANLUMPBUSICJ4BSLZ4IH5DZZ3JNBAVCNFSM6AAAAABPMJJ75OVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDGNBYG44DMNBRGY>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
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.
Awesome.
How about we make it more awesome and you right some basic docs too? Could be very basic at this stage, but I think we should make it a rule from now on (I'll discuss on our Monday call)
I assume undefined is the same as empty set, but I don't actually know. By that I mean not passing the named property is the same as passing an explicitly empty set.
Yeah, I need to add reference docs for the net module, so I'll do that, but I'll do it in a separate PR if that's alright. |
Sure |
No description provided.