diff options
Diffstat (limited to 'plugins/broadcast/root/rpc.go')
-rw-r--r-- | plugins/broadcast/root/rpc.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/plugins/broadcast/root/rpc.go b/plugins/broadcast/root/rpc.go new file mode 100644 index 00000000..5604a574 --- /dev/null +++ b/plugins/broadcast/root/rpc.go @@ -0,0 +1,25 @@ +package broadcast + +import "golang.org/x/sync/errgroup" + +type rpcService struct { + svc *Service +} + +// Publish Messages. +func (r *rpcService) Publish(msg []*Message, ok *bool) error { + *ok = true + return r.svc.Publish(msg...) +} + +// Publish Messages in async mode. Blocks until get an err or nil from publish +func (r *rpcService) PublishAsync(msg []*Message, ok *bool) error { + *ok = true + g := &errgroup.Group{} + + g.Go(func() error { + return r.svc.Publish(msg...) + }) + + return g.Wait() +} |