Documentation ¶
Overview ¶
This file contains the generic functions for handling different providers listener's and worker's task. ProcessMail & ProcessLog are identical functions and can be further merged into a single one but that would make managing the code more complex.
package Log Handles Log events pushed on the queue. Whenever a webhook event is recieved it is analysed for the state returned in it, it might happen that few emails are dropped or failed in during transmission by a Email service provider in that case we can retry sending the same email using the original content of the Batch from another provider.
The only caveat of this functionality is, email could have been dropped because of failed MX resolve in which case we will be wasting our bandwidth(todo: resolve MX) Emails can also be dropped if the gateway flags your email as a spam, in that case we should not aggresively retry sending the message as it will degrade the reputation and may cause your Email server to be flagged as a spammer.
Index ¶
- Constants
- Variables
- func GetMgEmailVars(options map[string]string, custom_args map[string]string) (string, error)
- func GetSgEmailVars(options map[string]string, custom_args map[string]string) (string, error)
- func InitMg()
- func InitSg()
- func MGListener(packet amqp.Delivery)
- func ProcessLog(packet amqp.Delivery, provider string, getEmailVarsFunc GetEmailVars, ...)
- func ProcessMail(packet amqp.Delivery, currentChannel string, getEmailVarsFunc GetEmailVars, ...)
- func SGListener(packet amqp.Delivery)
- func SendMgRequest(body *string) (int, bool, error)
- func SendSgRequest(body *string) (int, bool, error)
- type GetEmailVars
- type SendRequest
Constants ¶
const MAX_RETRY_COUNT = 6
Variables ¶
var MailGunClient *http.Client
var SendGridClient *http.Client
Functions ¶
func GetMgEmailVars ¶
Creates a JSON body out of options passed to it
func GetSgEmailVars ¶
Creates a JSON body out of options passed to it
func MGListener ¶
func ProcessLog ¶
func ProcessLog(packet amqp.Delivery, provider string, getEmailVarsFunc GetEmailVars, sendRequestFunc SendRequest)
Generic Function to process logs published for retrial @params:
packet : Rabbitmq packet provider: Provider name i.e. sendgrid, mailgun routingKey: Routing key intials i.e. "sglog.", "mglog.*" channel: The channel to which it has to retry publishing getEmailVarsFunc: A function which will return the body that has to be posted in request sendRequestFunc: A send helper function which dispatches the request to the known client
func ProcessMail ¶
func ProcessMail(packet amqp.Delivery, currentChannel string, getEmailVarsFunc GetEmailVars, sendRequestFunc SendRequest)