Streams Notifications
HI guys all rigth? how i can enable notifcations with streams? I 'm reading about stream in documentation website, but the sample is very simple. I lked to make system notifications with streams, for sample, redis connected in pubsub or rabbimq using repll to , postgresql using notify or one simple sample using sync.map and go rotine. thanks for advanced !!!
I am try this..
func main() {
reply := make(chan []byte)
RedisCnx.Subscribe("MENSAGEM-USER", reply)
e := echo.New()
e.HideBanner = true
e.GET("/teste", func(c echo.Context) error {
RedisCnx.Publish("MENSAGEM-USER", "AAAAAAA")
return c.String(http.StatusOK, "Hello, World!")
})
e.GET("/", func(c echo.Context) error {
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEOctetStream)
c.Response().WriteHeader(http.StatusOK)
for rep := range reply {
st := string(rep)
fmt.Println(st)
c.String(http.StatusOK, st)
c.Response().Flush()
}
return nil
})
e.Logger.Fatal(e.Start(AppPort))
}
Redis work!!! How i can send in frontend message ?
For frontend you probably want to use websockets https://echo.labstack.com/cookbook/websocket/
this is possible using stream of echo?
This is not an answer to your question, but it is a good solution for a similar situation. I tried using just sse (server sent event) without redis for this case. Simple, and effective.
thanks!!!