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 iron HTTP server #391

Merged
merged 10 commits into from
May 27, 2019
Merged

Add iron HTTP server #391

merged 10 commits into from
May 27, 2019

Conversation

paulhauner
Copy link
Member

Issue Addressed

NA

Proposed Changes

  1. Add an iron HTTP server with the following endpoints:
    • /metrics: Prometheus-format metrics.
    • /node/fork: returns the current fork.
  2. Creates the BeaconChainTypes super-type and threads it through the program.

Additional Info

Change #1 is the primary goal of this PR and change #2 helped facilitate it.

@paulhauner paulhauner added the work-in-progress PR is a work-in-progress label May 27, 2019
}

fn handle_fork<T: BeaconChainTypes + 'static>(req: &mut Request) -> IronResult<Response> {
// TODO: investigate unwrap - I'm _guessing_ we'll never hit it but we should check to be sure.
Copy link
Member

Choose a reason for hiding this comment

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

Yeah this should succeed so long as the persistent::Read has been linked (which it has)

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you think it would be prudent to create a conversion for this error into some IronResult?

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps some sort of 500 result.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, may as well avoid taking the whole node down. Looks like IronResult::new takes any std::Error and a response

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed!

);

// Any request to all other endpoints is handled by the `api` module.
router.any("/*", api::build_handler(beacon_chain.clone()), "api");
Copy link
Member

Choose a reason for hiding this comment

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

Another way to separate these is to "mount" the API handler on /api/, and the metrics handler on /metrics/ using the Mount middleware. Then we could have URLs like /api/node/fork, etc. Probably not worth changing for now, but would be worth thinking about once we have more APIs and we want to stabilise them

Copy link
Member

@michaelsproul michaelsproul 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 to me

@paulhauner paulhauner added work-in-progress PR is a work-in-progress and removed work-in-progress PR is a work-in-progress labels May 27, 2019
@paulhauner paulhauner merged commit 9922ed2 into master May 27, 2019
@paulhauner paulhauner deleted the http branch June 25, 2019 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work-in-progress PR is a work-in-progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants