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

Allow connectors to use async/await #1659

Open
5 tasks
bajtos opened this issue Nov 6, 2018 · 1 comment
Open
5 tasks

Allow connectors to use async/await #1659

bajtos opened this issue Nov 6, 2018 · 1 comment
Assignees
Labels

Comments

@bajtos
Copy link
Member

bajtos commented Nov 6, 2018

I would like to allow connector authors to use async functions instead of the current callback style.

Acceptance criteria

  • Define a new contract for connector: a connector provides a flag indicating whether it's callback based or async/promise based. We assume callbacks when the flag is not set (backward compatibility).
  • All DAO/KVAO methods need to be updated to check what flavor of flow control the connector support and invoke connector methods accordingly. Ideally, there should be a shared helper taking care of implementation details of consuming callback or promise style connectors.
  • Rework Connector and SqlConnector classes provided by loopback-connector to use async functions instead of callbacks everywhere. This is a semver-major change.
  • Rework the documentation for connector authors to use async functions instead of callbacks.
  • Add a new DataSource method execute that supports dual callback/promise API and under the hood calls connector's execute method using the correct style (callback/promise) as provided by the connector. EDIT: The method was already added by feat: dataSource.execute(cmd, args, opts) #1671, now we need to update it to support async execute provided by the connector.

Out of scope

Eventually we should update all of our connectors to use the new major version of loopback-connector and switch to async functions. There should be follow-up issues opened (one per the connector repository). Note that connectors using async functions become incompatible with LB 3.x projects (because they don't support connectors exporting async functions), the upgrade must be released as semver-major.

@dhmlau
Copy link
Member

dhmlau commented Sep 23, 2019

@markdirish, thanks for your interest in this GH issue, per the google group discussion. Marking this as "community contribution" as GH doesn't allow me to assign this task to you. Thanks!

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

No branches or pull requests

3 participants