diff options
author | Valery Piashchynski <[email protected]> | 2021-05-03 22:52:30 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-05-03 22:52:30 +0300 |
commit | 9ee78f937d5be67058882dd3590f89da35bca239 (patch) | |
tree | 17cda27feabf5f2b8afc6a2796117835045afd36 /plugins/broadcast/root/rpc.go | |
parent | 009b7009885d8a15e6fa6c7e78436087b2f20129 (diff) |
- Initial broadcast commit
Signed-off-by: Valery Piashchynski <[email protected]>
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() +} |