blob: 2fb0f1b9480ea7acf81d8070325610725c03f5e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package websockets
import (
"github.com/spiral/errors"
"github.com/spiral/roadrunner/v2/pkg/pubsub"
"github.com/spiral/roadrunner/v2/plugins/logger"
)
// rpc collectors struct
type rpc struct {
plugin *Plugin
log logger.Logger
}
func (r *rpc) Publish(msg []*pubsub.Message, ok *bool) error {
const op = errors.Op("broadcast_publish")
r.log.Debug("message published", "msg", msg)
// just return in case of nil message
if msg == nil {
*ok = true
return nil
}
err := r.plugin.Publish(msg)
if err != nil {
*ok = false
return errors.E(op, err)
}
*ok = true
return nil
}
func (r *rpc) PublishAsync(msg []*pubsub.Message, ok *bool) error {
r.log.Debug("message published", "msg", msg)
// just return in case of nil message
if msg == nil {
*ok = true
return nil
}
// publish to the registered broker
r.plugin.PublishAsync(msg)
*ok = true
return nil
}
|