mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-20 14:35:07 +00:00
Streams (#68)
This commit is contained in:
20
streams/handler/publish.go
Normal file
20
streams/handler/publish.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user