Multi-Provider
MultiProvider is itself a Provider that wraps several providers behind
one interface, selecting between them with StrategyFallback or
StrategyRoundRobin. Compose one and pass it straight to gosms.NewClient —
call sites don't change.
Fallback
Try providers in order until one succeeds. This is the default strategy:
multi := gosms.NewMultiProvider(twilioProvider, vonageProvider)
client := gosms.NewClient(multi)
result, err := client.Send(ctx, to, body)
Round-robin
Rotate across providers using an atomic counter:
multi := gosms.NewMultiProvider(twilioProvider, vonageProvider).
WithStrategy(gosms.StrategyRoundRobin)
client := gosms.NewClient(multi)
Behavior notes
Name()returns"multi".SendBulksends each message individually throughSend(so the selected strategy applies per message), collecting results withSendEach— a provider error for one message never aborts the batch.GetStatusqueries providers in order and returns the first successful lookup; if none succeed, it returnsgosms.ErrUnsupported.MultiProvideris safe for concurrent use — the round-robin counter is async/atomic.Uint64, and the strategy itself is guarded by aRWMutex.