pubsub

package
v0.0.0-...-b23f8ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TopicMessageSent = "message-sent"
	TopicChatCreated = "chat-created"
	TopicChatUpdated = "chat-updated"
)

Variables

This section is empty.

Functions

func NewMessageRouter

func NewMessageRouter(logger watermill.LoggerAdapter, handlers EventHandlers, pubsub PubSub) (*message.Router, error)

Types

type ChatCreated

type ChatCreated struct {
	ChatId    string    `json:"chat_id"`
	CreatedAt time.Time `json:"created_at"`
}

type ChatUpdated

type ChatUpdated struct {
	ChatId    string    `json:"chat_id"`
	UpdatedAt time.Time `json:"updated_at"`
}

type EventHandlers

type EventHandlers struct {
	MessageSent MessageSentHandler
}

func NewEventHandlers

func NewEventHandlers(ctx context.Context, logger watermill.LoggerAdapter) EventHandlers

type EventMessageSent

type EventMessageSent struct {
	Message Message   `json:"message"`
	ChatId  string    `json:"chat_id"`
	SentAt  time.Time `json:"sent_at,omitempty"`
}

type Message

type Message struct {
	AuthorId string `json:"author_id"`
	Text     string `json:"text"`
}

type MessageSentHandler

type MessageSentHandler struct {
	// contains filtered or unexported fields
}

func (MessageSentHandler) Handle

func (h MessageSentHandler) Handle(msg *message.Message) ([]*message.Message, error)

type PubSub

type PubSub interface {
	message.Publisher
	message.Subscriber
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL