loopbackio / loopbackio/loopback-datasource-juggler

Allow connectors to use async/await

Open
#1,659 1 comment 0 reactions 1 assignee View on GitHub

@markirish is already working on this.

Since Sep 24, 2019.

community-contribution feature help wanted major
Dominant language
JavaScript
Stars
282
Forks
366
Avg merge
17h 4m
Merged PRs (30d)
10

Description

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 https://github.com/strongloop/loopback-datasource-juggler/pull/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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.