Template
1
0
Fork 0
goth.stack/lib/sse.go
2024-01-17 12:02:03 -07:00

20 lines
449 B
Go

package lib
func SendSSE(channel string, message string) error {
// Create a channel to receive an error from the goroutine
errCh := make(chan error, 1)
// Use a goroutine to send the message asynchronously
go func() {
err := Publish(RedisClient, channel, message)
errCh <- err // Send the error to the channel
}()
// Wait for the goroutine to finish and check for errors
err := <-errCh
if err != nil {
return err
}
return nil
}