servers

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KafkaMQServer

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

func NewKafkaMQServer

func NewKafkaMQServer(c KafkaMQServerConfig, logger log.Logger) (*KafkaMQServer, error)

func (*KafkaMQServer) Consume

func (l *KafkaMQServer) Consume(topics []string, callback func(msg *kafka.Message) bool) error

Consume 消费多个topic kafka消息

func (*KafkaMQServer) Consumer

func (l *KafkaMQServer) Consumer() *kafka.Consumer

Consumer kafka消费者

func (*KafkaMQServer) Produce

func (l *KafkaMQServer) Produce(msg *kafka.Message) error

Produce kafka消息

func (*KafkaMQServer) Producer

func (l *KafkaMQServer) Producer() *kafka.Producer

Producer kafka生产者

type KafkaMQServerConfig

type KafkaMQServerConfig interface {
	GetEndpoints() []string
	GetGroupId() string
}

type Message

type Message struct {
	// 消息表现形式, 弹窗、提醒、通知
	MsgType MessageType `json:"msgType"`
	// 消息内容json
	Content any `json:"content"`
	// 消息标题
	Title string `json:"title"`
	// 消息业务类型
	Biz string `json:"biz"`
	// 用户ID
	UserId uint32 `json:"userId"`
}

func (*Message) Bytes

func (m *Message) Bytes() []byte

Bytes 返回消息的字节

type MessageType

type MessageType int32

type Timer

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

func NewTimer

func NewTimer(interval time.Duration, call TimerCall, logger log.Logger) *Timer

NewTimer 创建一个定时器

func (*Timer) Start

func (l *Timer) Start(ctx context.Context) (err error)

func (*Timer) Stop

func (l *Timer) Stop(ctx context.Context) error

type TimerCall

type TimerCall func(ctx context.Context)

type WebsocketServer

type WebsocketServer struct {
	StopCh chan struct{}
	// contains filtered or unexported fields
}

func NewWebsocketServer

func NewWebsocketServer(addr string) *WebsocketServer

func (*WebsocketServer) RegisterMessageHandler

func (l *WebsocketServer) RegisterMessageHandler(handler func(msg *Message))

RegisterMessageHandler 注册消息处理器

func (*WebsocketServer) SendMessage

func (l *WebsocketServer) SendMessage(message *Message)

SendMessage 发送消息

func (*WebsocketServer) Start

func (l *WebsocketServer) Start(_ context.Context) error

func (*WebsocketServer) Stop

func (l *WebsocketServer) Stop(_ context.Context) error

Jump to

Keyboard shortcuts

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