chore: stabilize lint and verify builds
This commit is contained in:
@@ -2,6 +2,7 @@ package event
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/ThreeDotsLabs/watermill"
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
@@ -22,12 +23,12 @@ func DefaultProvider() container.ProviderContainer {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Sql *ConfigSql
|
||||
SQL *ConfigSQL
|
||||
Kafka *ConfigKafka
|
||||
Redis *ConfigRedis
|
||||
}
|
||||
|
||||
type ConfigSql struct {
|
||||
type ConfigSQL struct {
|
||||
ConsumerGroup string
|
||||
}
|
||||
|
||||
@@ -50,24 +51,26 @@ type PubSub struct {
|
||||
|
||||
func (ps *PubSub) Serve(ctx context.Context) error {
|
||||
if err := ps.Router.Run(ctx); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("run event router: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// publish
|
||||
func (ps *PubSub) Publish(e contracts.EventPublisher) error {
|
||||
if e == nil {
|
||||
func (ps *PubSub) Publish(event contracts.EventPublisher) error {
|
||||
if event == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
payload, err := e.Marshal()
|
||||
payload, err := event.Marshal()
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("marshal event payload: %w", err)
|
||||
}
|
||||
|
||||
msg := message.NewMessage(watermill.NewUUID(), payload)
|
||||
return ps.getPublisher(e.Channel()).Publish(e.Topic(), msg)
|
||||
|
||||
return ps.getPublisher(event.Channel()).Publish(event.Topic(), msg)
|
||||
}
|
||||
|
||||
// getPublisher returns the publisher for the specified channel.
|
||||
@@ -75,6 +78,7 @@ func (ps *PubSub) getPublisher(channel contracts.Channel) message.Publisher {
|
||||
if pub, ok := ps.publishers[channel]; ok {
|
||||
return pub
|
||||
}
|
||||
|
||||
return ps.publishers[Go]
|
||||
}
|
||||
|
||||
@@ -82,6 +86,7 @@ func (ps *PubSub) getSubscriber(channel contracts.Channel) message.Subscriber {
|
||||
if sub, ok := ps.subscribers[channel]; ok {
|
||||
return sub
|
||||
}
|
||||
|
||||
return ps.subscribers[Go]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user