notifme / notifme-sdk

A Node.js library to send all kinds of transactional notifications.
https://notifme.github.io/www/
MIT License
1.94k stars 149 forks source link

Multi provider strategy #13

Closed jnoleau closed 7 years ago

jnoleau commented 7 years ago

Make generic the strategy attached to a channel.

The idea is to be able to define a function implementing the strategy. A strategy takes all provider in input and return a "new" provider.

channels {
  sms: {
    providers: [...]
    multiProviderStrategy: string /* actual*/  
            | (SmsProviderInstance[]) => ((req) => Promise<string>)
  }
}

Refactor existing strategies would be easy

fallback : (providers) => // try with the first and recursively try on error round-robin (no-fallback) : (providers) => provider[n]

BDav24 commented 7 years ago

https://github.com/notifme/notifme-sdk/pull/14