tlmq

package
v0.0.0-...-1b3fcde Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Copyright (c) 2023, donnie <donnie4w@gmail.com> All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

github.com/donnie4w/tldb

Copyright (c) 2023, donnie <donnie4w@gmail.com> All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

github.com/donnie4w/tldb

Copyright (c) 2023, donnie <donnie4w@gmail.com> All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

github.com/donnie4w/tldb

Index

Constants

View Source
const (
	MQ_AUTH      byte = 1
	MQ_PUBBYTE   byte = 2
	MQ_PUBJSON   byte = 3
	MQ_SUB       byte = 4
	MQ_PULLBYTE  byte = 5
	MQ_PULLJSON  byte = 6
	MQ_PING      byte = 7
	MQ_ERROR     byte = 8
	MQ_PUBMEM    byte = 9
	MQ_RECVACK   byte = 10
	MQ_MERGE     byte = 11
	MQ_SUBCANCEL byte = 12
	MQ_CURRENTID byte = 13
	MQ_ZLIB      byte = 14
	MQ_LOCK      byte = 15
	MQ_ACK       byte = 0

	MQ_ERROR_PUBBYTE   int64 = 1201 // 发布pubByte错误
	MQ_ERROR_PUBJSON   int64 = 1202 // 发布pubJson错误
	MQ_ERROR_PULLBYTE  int64 = 1203 // 发布pullByte错误
	MQ_ERROR_PULLJSON  int64 = 1204 // 发布pullJson错误
	MQ_ERROR_PUBMEM    int64 = 1205 // 发布pubMem错误
	MQ_ERROR_CURRENTID int64 = 1206 // 发布CURRENTID错误
	MQ_ERROR_NOPASS    int64 = 1301 // 验证不通过
)

Variables

View Source
var CliWare = NewMap[int64, *WsSock]()
View Source
var MqWare = NewMqEngine()
View Source
var WsWare = NewMapL[int64, *WsSock]()

Functions

func AddConn

func AddConn(ws *tlnet.Websocket, cliId int64) (err error)

func Close

func Close(wsId int64)

func DelAckId

func DelAckId(wsid, ackid int64)

func IsRecvAckOn

func IsRecvAckOn(id int64) (_r bool)

func JEncode

func JEncode(mb *JMqBean) (bs []byte)

func MQDecode

func MQDecode[T thrift.TStruct](bs []byte, ts T) (_r T, err error)

func MQEncode

func MQEncode(ts thrift.TStruct) (_r []byte)

****************************************

func SetJsonOn

func SetJsonOn(id int64, topic string, on bool)

func SetMergeOn

func SetMergeOn(id int64, size int8)

func SetRecvAck

func SetRecvAck(id int64, sec int8)

func SetZlib

func SetZlib(id int64, on bool)

Types

type JMqBean

type JMqBean struct {
	Id    int64
	Topic string
	Msg   string
}

func JDecode

func JDecode(bs []byte) (mb *JMqBean, err error)

type MqEg

type MqEg interface {
	AddConn(topic string, ws *tlnet.Websocket)
	DelConn(id int64)
	SubCount(topic string) (_r int64)
	DelTopic(topic string)
	DelTopicWithID(topic string, id int64)
	ClusPub(mqType int8, bs []byte) (err error)
	PubByte(mb *MqBean, wsId int64, self bool) (err error)
	PubJson(mb *JMqBean, wsId int64, self bool) (err error)
	PubMem(mb *JMqBean, wsId int64, self bool)
	PullByte(mb *MqBean, id int64) (err error)
	PullJson(mb *JMqBean, id int64) (err error)
	PullId(id int64) (err error)
	Ping(buf *bytes.Buffer, id int64)
	Ack(buf *bytes.Buffer, id int64)
}

func NewMqEngine

func NewMqEngine() MqEg

///////////////////////////////////////////

type WsSock

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

func NewWsSock

func NewWsSock(ws *tlnet.Websocket, cliId int64) (_r *WsSock)

func (*WsSock) AckTimer

func (this *WsSock) AckTimer()

func (*WsSock) DelAckId

func (this *WsSock) DelAckId(id int64)

func (*WsSock) MergeSend

func (this *WsSock) MergeSend(buf *bytes.Buffer)

func (*WsSock) Send

func (this *WsSock) Send(buf *bytes.Buffer) (err error)

func (*WsSock) SendWithAck

func (this *WsSock) SendWithAck(buf *bytes.Buffer) (err error)

func (*WsSock) SetJsonOn

func (this *WsSock) SetJsonOn(topic string, on bool)

func (*WsSock) SetMergeOn

func (this *WsSock) SetMergeOn(size int8)

func (*WsSock) SetRecvAckOn

func (this *WsSock) SetRecvAckOn(sec int8)

func (*WsSock) SetZlib

func (this *WsSock) SetZlib(zlib bool)

Jump to

Keyboard shortcuts

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