I am working on smtp library to act as mux for smpt. User define config with multiple smtp downstream servers and the service. This service will act as proxy between down streams and upstream. Purpose is to intelligently route traffic to needed provider. By default I can provide roundrobin or watterfall (try all providers in seq until one succeeds). This much is done. To make it more extensible - I am thinking of letting user provide their own implementations kind of like plugins. Ideally this will be running as docker, users can mount their plugin and update config to use that plugin. So far I've successfully implemented this using starlank. I've never used starlank my self before and used some llm and google to make it working. But I am wondering if there is some better solution? When I say - better, I mean something in go it self? Because I am thinking of creating a routing logic which might need some state management. To clarify on this - there can be two downstream SMTP providers with each having their own set of hourly limits. There for the router can maintain the state and make routing decisions based on this. I donot want to make assumptions on what can be the possible variables there might be. So in ideal world user will provide there go implementation of routing_rule interface and I'll simply call it.
// user implementation
type myStartRouter struct {
rateLimits map[string]RateLimitConfig // {"gmail":{...}, "sendgrid":{...}
}
func NewRouter(config Config){
return &mySmartRouterRule{....}
}
func Route(downstreams []DownStream) (DownStream, error) {
.....
return downstream, nil
}
// backend service
....
router := getRouter(config)
router.Route(config).send(..)
...