Yes! As comments stated you can spawn a new go routine within the context of your view. The goroutine gets its own stack and allows it to operate "asynchronously" from the view handling function:
func ApiView(w http.ResponseWriter, req *http.Request){
//logic
// need to call email/sms service
go sendEmail(someEmailAddress)
fmt.Fprintf(w, "TEST")
}
This will execute sendEmail
using a go routine and immediately write TEST
to the caller.
While trivial it is not equivalent to celery redis/rabbitmq:
- How do you handle failures?
- How do you bound concurrency (worker pool)
- How do you buffer tasks? (ie currently in rabbitmq it is out of process)
- How do you retry?
- Should the async task be in a different process/memory space?
None of the above are particularly difficult, and completely doable (and plenty of patterns/blogs/libraries exist for doing this exact thing)