Finished
This commit is contained in:
20
lib/sse.go
Normal file
20
lib/sse.go
Normal file
@ -0,0 +1,20 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user