added events
This commit is contained in:
parent
1b5fc6bda9
commit
f253292898
5 changed files with 28 additions and 1 deletions
19
bootstrap/app/events.go
Normal file
19
bootstrap/app/events.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"AABBCCDD/app/events"
|
||||
|
||||
"github.com/anthdm/gothkit/event"
|
||||
)
|
||||
|
||||
// Events are functions that are handled in separate goroutines.
|
||||
// They are the perfect fit for offloading work in your handlers
|
||||
// that otherwise would take up response time.
|
||||
// - sending email
|
||||
// - sending notifications (Slack, Telegram, Discord)
|
||||
// - analytics..
|
||||
|
||||
// Register your events here.
|
||||
func RegisterEvents() {
|
||||
event.Subscribe("foo.bar", events.HandleFooEvent)
|
||||
}
|
|
@ -2,4 +2,7 @@ package events
|
|||
|
||||
import "context"
|
||||
|
||||
// Event handlers
|
||||
func HandleFooEvent(ctx context.Context, event any) {}
|
||||
|
||||
// func HandleFooEvent(ctx context.Context, event any) {}
|
||||
|
|
|
@ -23,6 +23,7 @@ func main() {
|
|||
router.HandleFunc("/*", kit.Handler(app.NotFoundHandler))
|
||||
|
||||
app.InitializeRoutes(router)
|
||||
app.RegisterEvents()
|
||||
|
||||
fmt.Printf("application running in %s at %s\n", kit.Env(), "http://localhost:7331")
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ require (
|
|||
|
||||
require (
|
||||
github.com/a-h/templ v0.2.707 // indirect
|
||||
github.com/anthdm/gothkit v0.0.0-20240606141535-31a222db1a4a // indirect
|
||||
github.com/anthdm/gothkit v0.0.0-20240607090309-1b5fc6bda9a4 // indirect
|
||||
github.com/go-chi/chi/v5 v5.0.12 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
|
||||
|
|
|
@ -3,6 +3,10 @@ github.com/a-h/templ v0.2.707/go.mod h1:5cqsugkq9IerRNucNsI4DEamdHPsoGMQy99DzydL
|
|||
github.com/anthdm/gothkit v0.0.0-20240606095122-e65b6d50b1a7/go.mod h1:QLre7XyvsU9RKQKh0XFXUX+L5Lfph2jViZgtdfIDKsQ=
|
||||
github.com/anthdm/gothkit v0.0.0-20240606141535-31a222db1a4a h1:0g//UhjEaQsXsNXrZaXvlFIIpNcTi44AW2s5GwFvl6o=
|
||||
github.com/anthdm/gothkit v0.0.0-20240606141535-31a222db1a4a/go.mod h1:ppehL6Nf6qf1HiozXFELwbh84SDR/aO9zdHmcJwxNng=
|
||||
github.com/anthdm/gothkit v0.0.0-20240607073122-99cbc94b2cc1 h1:xYWzcL00bz5nlYIXe23l61h8ry539wK83CXXw+w6evw=
|
||||
github.com/anthdm/gothkit v0.0.0-20240607073122-99cbc94b2cc1/go.mod h1:ppehL6Nf6qf1HiozXFELwbh84SDR/aO9zdHmcJwxNng=
|
||||
github.com/anthdm/gothkit v0.0.0-20240607090309-1b5fc6bda9a4 h1:VFCgfPhlyhZk56NauI+TBhKJC1mR3ICfX+7Q28EVbB8=
|
||||
github.com/anthdm/gothkit v0.0.0-20240607090309-1b5fc6bda9a4/go.mod h1:ppehL6Nf6qf1HiozXFELwbh84SDR/aO9zdHmcJwxNng=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
|
||||
|
|
Loading…
Reference in a new issue