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

Add std::net::http::schedule_request function #7831

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

scotttrinh
Copy link
Contributor

No description provided.

@scotttrinh scotttrinh requested review from fantix and dnwpark October 4, 2024 17:23
Copy link
Member

@fantix fantix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

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`,
Copy link
Member

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 🤔

Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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 🤔

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@fantix
Copy link
Member

fantix commented Oct 4, 2024 via email

Copy link
Member

@1st1 1st1 left a 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)

@scotttrinh
Copy link
Contributor Author

@fantix

Does optional allow passing in an empty set explicitly?

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.

@1st1

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)

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.

@1st1
Copy link
Member

1st1 commented Oct 4, 2024

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

@scotttrinh
Copy link
Contributor Author

cc @1st1
Super quick wip draft for the basic docs: #7833

Not ready, but wanted to link here for posterity.

@scotttrinh scotttrinh requested a review from fantix October 5, 2024 01:12
@scotttrinh scotttrinh merged commit 685df34 into master Oct 7, 2024
23 checks passed
@scotttrinh scotttrinh deleted the 7727-http-schedule-request branch October 7, 2024 12:55
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.

3 participants