Skip to content

Commit

Permalink
Add interface in topic
Browse files Browse the repository at this point in the history
  • Loading branch information
mpsdantas committed Mar 15, 2024
1 parent 97fef52 commit 48cbc71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/pubsub/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func (c *Client) Close() {
}
}

func (c *Client) Topic(id string) *Topic {
return &Topic{
func (c *Client) Topic(id string) Topic {
return &topic{
tp: c.clt.Topic(id),
}
}
8 changes: 6 additions & 2 deletions pkg/pubsub/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ import (
"github.com/mpsdantas/bottle/pkg/log"
)

type Topic struct {
type Topic interface {
Publish(ctx context.Context, event string, value interface{})
}

type topic struct {
tp *pubsub.Topic
}

func (t *Topic) Publish(ctx context.Context, event string, value interface{}) {
func (t *topic) Publish(ctx context.Context, event string, value interface{}) {
go func(c context.Context) {
data, err := json.Marshal(value)
if err != nil {
Expand Down

0 comments on commit 48cbc71

Please sign in to comment.