We are planning to move to golang from django.
To send an email or sms, we do celery workers with redis/rabbotmq in Django. But how can we do that background tasks on golang.
Eg:
def api_view():
// logic
// celery tasks- call email/sms service
// immediate response to client
return Response()
How can we do in golang
fun ApiView(w http.ResponseWriter, req *http.Request){
//logic
// need to call email/sms service
fmt.Fprintf(w, "TEST")
}
Is there anything we can start new go routine (without additional redis/workers) inside the API view of gorilla/mux ?
Thanks.
go
statement, e.g.go sendEmail(arg1, arg2)
. Read more here.sendEmail
terminates, thego
routine terminates. WhenApiView
terminates it will not terminatesendEmail
if it is still running.