This commit is contained in:
ben-toogood
2021-02-08 14:42:47 +00:00
committed by GitHub
parent f4ad5d6bd2
commit 6e49584049
16 changed files with 1202 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
package handler
import (
"context"
pb "github.com/micro/services/streams/proto"
)
func (s *Streams) Publish(ctx context.Context, req *pb.Message, rsp *pb.PublishResponse) error {
// validate the request
if len(req.Topic) == 0 {
return ErrMissingTopic
}
if len(req.Message) == 0 {
return ErrMissingMessage
}
// publish the message
return s.Events.Publish(req.Topic, req.Message)
}