remove: tenantslug
This commit is contained in:
48
backend/app/events/subscribers/post_updated.go
Normal file
48
backend/app/events/subscribers/post_updated.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package subscribers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"backend/app/events"
|
||||
"backend/app/events/publishers"
|
||||
|
||||
"git.ipao.vip/rogeecn/atom/contracts"
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var _ contracts.EventHandler = (*PostUpdatedSubscriber)(nil)
|
||||
|
||||
// @provider(event)
|
||||
type PostUpdatedSubscriber struct {
|
||||
log *logrus.Entry `inject:"false"`
|
||||
}
|
||||
|
||||
func (e *PostUpdatedSubscriber) Prepare() error {
|
||||
e.log = logrus.WithField("module", "events.subscribers.PostUpdatedSubscriber")
|
||||
return nil
|
||||
}
|
||||
|
||||
// PublishToTopic implements contracts.EventHandler.
|
||||
func (e *PostUpdatedSubscriber) PublishToTopic() string {
|
||||
return events.TopicProcessed
|
||||
}
|
||||
|
||||
// Topic implements contracts.EventHandler.
|
||||
func (e *PostUpdatedSubscriber) Topic() string {
|
||||
return events.TopicPostUpdated
|
||||
}
|
||||
|
||||
// Handler implements contracts.EventHandler.
|
||||
func (e *PostUpdatedSubscriber) Handler(msg *message.Message) ([]*message.Message, error) {
|
||||
var payload publishers.PostUpdatedEvent
|
||||
err := json.Unmarshal(msg.Payload, &payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
e.log.Infof("received event %s", msg.Payload)
|
||||
|
||||
// TODO: handle post deletion
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
Reference in New Issue
Block a user