Allow connectors to use async/await

Aperta
#1,659 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@markirish ci sta già lavorando.

Dal 24/9/2019.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

community-contribution feature help wanted major

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.

Lingua principale
JavaScript
Stelle
279
Fork
362
Merge medio
21h 14m
PR unite (30g)
16

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di loopbackio/loopback-datasource-juggler

Tutte le issue di loopbackio/loopback-datasource-juggler

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.