echo icon indicating copy to clipboard operation
echo copied to clipboard

Streams Notifications

Open johndiego opened this issue 3 years ago • 3 comments

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 !!!

johndiego avatar Mar 10 '22 19:03 johndiego

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 ?

johndiego avatar Mar 11 '22 17:03 johndiego

For frontend you probably want to use websockets https://echo.labstack.com/cookbook/websocket/

aldas avatar Mar 12 '22 15:03 aldas

this is possible using stream of echo?

johndiego avatar Mar 16 '22 21:03 johndiego

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.

baxiry avatar Oct 27 '22 14:10 baxiry

thanks!!!

johndiego avatar Nov 08 '22 02:11 johndiego