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

Implements custom resolvers #6132

Closed
wants to merge 6 commits into from
Closed

Conversation

arcanis
Copy link

@arcanis arcanis commented Apr 12, 2018

This diff adds a new configuration option to Flow: module_resolver. It points to an executable that consumes a stream of JSON objects under the form [request, issuer], and outputs a stream of paths in response.

Since it's been my first work with OCaml since quite a long time there's probably errors and odity in my code, feel free to point them 🙂 Some of them I have in mind (maybe they can be fixed in a followup pass, you tell me):

  • The JSON payload is crafted with sprintf, I wasn't sure how to properly generate a JSON string
  • For the same reason, the resolver returns a stream of paths instead of an actual JSON object because I wasn't sure how to parse them in Flow
  • Related to the previous point, the resolver doesn't have a way to notify Flow that a request cannot be satisfied (it would be solved if the return object was a [err, result] entity).
  • If the module_resolver is invalid, Flow will currently hang (I thought create_process would "throw", but maybe it doesn't make sense in OCaml?)

@arcanis
Copy link
Author

arcanis commented Apr 12, 2018

cc @mroch

@arcanis
Copy link
Author

arcanis commented Apr 12, 2018

The Appveyor error seems unrelated (sqlite3), and the Travis one is one that I cannot reproduce locally (I had it some time ago, but then I updated the mli file to include module_resolver and it worked). Could it be possible that the mli file is cached somewhere?

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@arcanis has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@arcanis has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@arcanis has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@arcanis has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@arcanis has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@fatfatson
Copy link

could this solve #6305 ?

nmote pushed a commit that referenced this pull request Jun 5, 2018
Summary:
This diff adds a new configuration option to Flow: `module_resolver`. It points to an executable that consumes a stream of JSON objects under the form `[request, issuer]`, and outputs a stream of paths in response.

Since it's been my first work with OCaml since quite a long time there's probably errors and odity in my code, feel free to point them 🙂 Some of them I have in mind (maybe they can be fixed in a followup pass, you tell me):

- The JSON payload is crafted with sprintf, I wasn't sure how to properly generate a JSON string
- For the same reason, the resolver returns a stream of paths instead of an actual JSON object because I wasn't sure how to parse them in Flow
- Related to the previous point, the resolver doesn't have a way to notify Flow that a request cannot be satisfied (it would be solved if the return object was a `[err, result]` entity).
- If the `module_resolver` is invalid, Flow will currently hang (I thought `create_process` would "throw", but maybe it doesn't make sense in OCaml?)
Closes #6132

Reviewed By: gabelevi

Differential Revision: D7619501

Pulled By: arcanis

fbshipit-source-id: a4bf8b89a6f94a8f1e8dac92ae1789a3c7be77f2
@jakesylvestre
Copy link

@arcanis, if you have a second it'll be super helpful if you could look at #7014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants