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

Introduce a StatusCode type to represent statuses #474

Merged
merged 1 commit into from
Jun 3, 2022

Conversation

caspervonb
Copy link
Collaborator

No description provided.

async-nats/src/status.rs Outdated Show resolved Hide resolved
@caspervonb caspervonb marked this pull request as draft June 2, 2022 16:01
@caspervonb caspervonb requested a review from Jarema June 2, 2022 16:01

impl fmt::Display for InvalidStatusCode {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("invalid status code")
Copy link
Member

Choose a reason for hiding this comment

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

without knowing the actuall invalid status code user (and so we are) helpless here.

Why to store error code?

Copy link
Collaborator Author

@caspervonb caspervonb Jun 3, 2022

Choose a reason for hiding this comment

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

Clamping to http status code range (100..1000) for sanity and easier from str parsing (only 3 digits to parse).

NATS server doesn't use the entire range (need to double check but think we're using 400-600 currently) but leaving us some room for expansions.

Also heavily borrowing/yanking from the http crate here.

I think you're wanting to store the code that was deemed invalid in the error?

Copy link
Member

@Jarema Jarema Jun 3, 2022

Choose a reason for hiding this comment

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

yeah, that was my idea, to store that code here.

Copy link
Collaborator Author

@caspervonb caspervonb Jun 3, 2022

Choose a reason for hiding this comment

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

Would require two errors at-least (because of the conversion its coming from is either str or u16), so punting for now if you don't mind 😁 (Really should not happen in normal flow from server).

@caspervonb caspervonb force-pushed the feat-status-code branch 6 times, most recently from b819d3c to fdaf332 Compare June 3, 2022 12:00
@caspervonb caspervonb marked this pull request as ready for review June 3, 2022 12:03
This introduces a `StatusCode` type modeled after HTTP status codes but
adapted to known NATS constants.
Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

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

LGTM

@caspervonb caspervonb merged commit 3d7f742 into nats-io:main Jun 3, 2022
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.

2 participants