notifme / notifme-sdk

A Node.js library to send all kinds of transactional notifications.

Home Page:https://notifme.github.io/www/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multi provider strategy

jnoleau opened this issue · comments

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]