mq

package
v0.0.0-...-3cdc2b7 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignalClearConsumers string = "SIGNAL_CLEAR_CONSUMERS"
	SignalAddConsumers   string = "SIGNAL_ADD_CONSUMERS"
)
View Source
const (
	SignalClearConsumersComplete string = "ccc"
)

Variables

View Source
var CleanUpChans map[uint]map[string]chan bool

user id -> group topic -> complete

Functions

func NewConsumer

func NewConsumer(topic, ch string) (*nsq.Consumer, error)

func Publish

func Publish[T Message](host string, topic string, message T) error

func StopProducers

func StopProducers()

Types

type BroadCastMessage

type BroadCastMessage struct {
	From User
	Body []byte
}

type ConnDelegate

type ConnDelegate struct{}

func (*ConnDelegate) OnBackoff

func (d *ConnDelegate) OnBackoff(*nsq.Conn)

func (*ConnDelegate) OnClose

func (d *ConnDelegate) OnClose(*nsq.Conn)

func (*ConnDelegate) OnContinue

func (d *ConnDelegate) OnContinue(*nsq.Conn)

func (*ConnDelegate) OnError

func (d *ConnDelegate) OnError(*nsq.Conn, []byte)

func (*ConnDelegate) OnHeartbeat

func (d *ConnDelegate) OnHeartbeat(*nsq.Conn)

func (*ConnDelegate) OnIOError

func (d *ConnDelegate) OnIOError(*nsq.Conn, error)

func (*ConnDelegate) OnMessage

func (d *ConnDelegate) OnMessage(*nsq.Conn, *nsq.Message)

func (*ConnDelegate) OnMessageFinished

func (d *ConnDelegate) OnMessageFinished(*nsq.Conn, *nsq.Message)

func (*ConnDelegate) OnMessageRequeued

func (d *ConnDelegate) OnMessageRequeued(*nsq.Conn, *nsq.Message)

func (*ConnDelegate) OnResponse

func (d *ConnDelegate) OnResponse(*nsq.Conn, []byte)

func (*ConnDelegate) OnResume

func (d *ConnDelegate) OnResume(*nsq.Conn)

type ExchangeMessage

type ExchangeMessage struct {
	Type          string          `json:"type"`
	UserID        uint            `json:"user_id"`
	TargetID      uint            `json:"target_id"`
	TargetType    string          `json:"target_type"`
	Topic         string          `json:"topic"`
	PostbackTopic string          `json:"postback_topic"`
	PostbackCh    string          `json:"postback_ch"`
	PostbackMsg   *PrivateMessage `json:"postback_message"`
}

type Handler

type Handler struct{}

func (*Handler) HandleMessage

func (h *Handler) HandleMessage(m *nsq.Message) error

type Message

type Message interface {
	*BroadCastMessage | *ExchangeMessage | *PrivateMessage
}

type PrivateMessage

type PrivateMessage struct {
	Type   string `json:"type"`
	UserID uint   `json:"user_id"`
	Topic  string `json:"topic"`
}

type User

type User struct {
	model.Base
	Username    string `json:"username"`
	Displayname string `json:"displayname"`
	ImageURL    string `json:"image_url"`
}

Jump to

Keyboard shortcuts

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