Documentation
¶
Index ¶
- Constants
- Variables
- func EmptyCount(num int) []byte
- func FillEmpty(in string, num int) []byte
- func HandleRead(goroutineName string, ctx context.Context, cancel context.CancelFunc, ...)
- func HandleWrite(goroutineName string, ctx context.Context, cancel context.CancelFunc, ...)
- func InitGlobalCmppManager(goroutineCount int, goroutinePrefix string, recordCount int64, ...)
- func PrettyHeader(goroutinePrefix string, goroutineCount int, recordCount int) string
- func PrettyString(...) string
- func ReleaseCmppActiveTest(cat *CmppActiveTest)
- func ReleaseCmppActiveTestResp(catr *CmppActiveTestResp)
- func ReleaseCmppConnect(ccq *CmppConnect)
- func ReleaseCmppConnectResp(ccr *CmppConnectResp)
- func ReleaseCmppDeliver(cdq *CmppDeliver)
- func ReleaseCmppDeliverResp(cdr *CmppDeliverResp)
- func ReleaseCmppResult(cr *CmppResult)
- func ReleaseCmppSubmit(cs *CmppSubmit)
- func ReleaseCmppSubmitResp(csr *CmppSubmitResp)
- func Run()
- func SequenceIdAdd() uint32
- func StartCmppClient(goroutineName string)
- type Cmpp
- type CmppActiveTest
- type CmppActiveTestResp
- type CmppConnect
- type CmppConnectResp
- type CmppDeliver
- type CmppDeliverResp
- type CmppManager
- type CmppResult
- type CmppSubmit
- type CmppSubmitResp
- type CmppType
- type Statistics
Constants ¶
View Source
const ( CMPPCONNECTREQUEST CmppType = 0x00000001 CMPPCONNECTRESPONSE CmppType = 0x80000001 CMPPTERMINATEREQUEST CmppType = 0x00000002 CMPPTERMINATERESPONSE CmppType = 0x80000002 CMPPSUBMITREQUEST CmppType = 0x00000004 CMPPSUBMITRESPONSE CmppType = 0x80000004 CMPPDELIVERREQUEST CmppType = 0x00000005 CMPPDELIVERRESPONSE CmppType = 0x80000005 CMPPACTIVETESTREQUEST CmppType = 0x00000008 CMPPACTIVETESTRESPONSE CmppType = 0x80000008 Empty = byte(0x00) DeliverySucc string = "DELIVRD" )
Variables ¶
View Source
var ( CmppConnectPool sync.Pool CmppConnectRespPool sync.Pool CmppActiveTestPool sync.Pool CmppActiveTestRespPool sync.Pool CmppSubmitPool sync.Pool CmppSubmitRespPool sync.Pool CmppDeliverPool sync.Pool CmppDeliverRespPool sync.Pool CmppResultPool sync.Pool )
View Source
var ( SequenceId uint32 HealthCheckId uint32 //10字节 EmptyServiceId = EmptyCount(10) //21字节 EmptyFeeTerminalId = EmptyCount(21) // EmptyFeeCode = []byte{0x30, 0x30, 0x30, 0x30, 0x30, 0x30} EmptyValidTime = EmptyCount(17) EmptyAtTime = EmptyCount(17) EmptyReserve = EmptyCount(8) GlobalPretttyHeader string GlobalServerAddr string GlobalSpId string GlobalSpPassword string GlobalSrcId string GlobalHostname string GlobalPhoneContentChan chan string GlobalCmppWriteChan = make(chan []byte, 10000) GlobalResultSlice = []*CmppResult{} GlobalLock = &sync.Mutex{} GlobalLogger = log.InitLogger("cmpp.log", 30, 7, 7, false, false) )
Functions ¶
func EmptyCount ¶
func HandleRead ¶
func HandleRead(goroutineName string, ctx context.Context, cancel context.CancelFunc, conn net.Conn, bufferRecv []byte)
HandleRead(ctx, cancel, conn, bufferRecv, cmppWriteChan)
func HandleWrite ¶
func InitGlobalCmppManager ¶
func PrettyHeader ¶
func PrettyString ¶
func PrettyString(goroutineName, state, writeCount, submitRespCount, readCount, costTotal, costLast, avgCount string) string
goroutine:%s|总共发送:%v|总共读取:%v|总共耗时:%s|最近%d条耗时%s|平均每秒发送数量:%v\n goroutine name|goroutine state|submit number|submit resp number|deliver number|time cost total|time cost last 1000 record|submit per second goroutine-0 |running |40088 |0 |14.87581438s |651.91777ms |2863
func ReleaseCmppActiveTest ¶
func ReleaseCmppActiveTest(cat *CmppActiveTest)
func ReleaseCmppActiveTestResp ¶
func ReleaseCmppActiveTestResp(catr *CmppActiveTestResp)
func ReleaseCmppConnect ¶
func ReleaseCmppConnect(ccq *CmppConnect)
func ReleaseCmppConnectResp ¶
func ReleaseCmppConnectResp(ccr *CmppConnectResp)
func ReleaseCmppDeliver ¶
func ReleaseCmppDeliver(cdq *CmppDeliver)
func ReleaseCmppDeliverResp ¶
func ReleaseCmppDeliverResp(cdr *CmppDeliverResp)
func ReleaseCmppResult ¶
func ReleaseCmppResult(cr *CmppResult)
func ReleaseCmppSubmit ¶
func ReleaseCmppSubmit(cs *CmppSubmit)
func ReleaseCmppSubmitResp ¶
func ReleaseCmppSubmitResp(csr *CmppSubmitResp)
func SequenceIdAdd ¶
func SequenceIdAdd() uint32
func StartCmppClient ¶
func StartCmppClient(goroutineName string)
phoneChan以及contentChan需要自己实现,可以从 这2个channel中获取手机号以及短信内容
Types ¶
type CmppActiveTest ¶
type CmppActiveTest struct { MsgLength uint32 //4个字节 CommandId uint32 //4个字节 SequenceId uint32 //4个字节 }
func AcquireCmppActiveTest ¶
func AcquireCmppActiveTest() *CmppActiveTest
func (*CmppActiveTest) Codec ¶
func (cat *CmppActiveTest) Codec() []byte
func (*CmppActiveTest) Decodec ¶
func (cat *CmppActiveTest) Decodec(b []byte) error
func (*CmppActiveTest) Fullup ¶
func (cat *CmppActiveTest) Fullup()
func (*CmppActiveTest) Reset ¶
func (cat *CmppActiveTest) Reset()
type CmppActiveTestResp ¶
type CmppActiveTestResp struct { MsgLength uint32 //4个字节 CommandId uint32 //4个字节 SequenceId uint32 //4个字节 Status uint8 //4个字节 }
func AcquireCmppActiveTestResp ¶
func AcquireCmppActiveTestResp() *CmppActiveTestResp
func (*CmppActiveTestResp) Codec ¶
func (catr *CmppActiveTestResp) Codec() []byte
func (*CmppActiveTestResp) Decodec ¶
func (catr *CmppActiveTestResp) Decodec(b []byte) error
func (*CmppActiveTestResp) Fullup ¶
func (catr *CmppActiveTestResp) Fullup(sequenceId uint32)
func (*CmppActiveTestResp) Reset ¶
func (catr *CmppActiveTestResp) Reset()
type CmppConnect ¶
type CmppConnect struct { MsgLength uint32 //4个字节 CommandId uint32 //4个字节 SequenceId uint32 //4个字节 SourceAddr string //6个字节例如 111222 SourcePassword string // 16个字节,密码md5加密生成32位字符串,取中间的16位 Version uint8 //版本号 1个字节 Timestamp uint32 //时间戳 4个字节 }
func AcquireCmppConnect ¶
func AcquireCmppConnect() *CmppConnect
*************************************************************
func (*CmppConnect) Codec ¶
func (ccq *CmppConnect) Codec() []byte
func (*CmppConnect) Decodec ¶
func (ccq *CmppConnect) Decodec(b []byte) error
func (*CmppConnect) Fullup ¶
func (ccq *CmppConnect) Fullup(sourceAddr, sourcePassword string)
func (*CmppConnect) Reset ¶
func (ccq *CmppConnect) Reset()
type CmppConnectResp ¶
type CmppConnectResp struct { MsgLength uint32 //4个字节 CommandId uint32 //4个字节 0x80000001 SequenceId uint32 //4个字节 Status uint8 //1个字节 AuthenticatiorIsmg string // 16个字节 Version uint8 // 1字节 }
func AcquireCmppConnectResp ¶
func AcquireCmppConnectResp() *CmppConnectResp
func (*CmppConnectResp) Codec ¶
func (ccr *CmppConnectResp) Codec() []byte
func (*CmppConnectResp) Decodec ¶
func (ccr *CmppConnectResp) Decodec(b []byte) error
func (*CmppConnectResp) Fullup ¶
func (ccr *CmppConnectResp) Fullup()
func (*CmppConnectResp) Reset ¶
func (ccr *CmppConnectResp) Reset()
type CmppDeliver ¶
type CmppDeliver struct { MsgLength uint32 //4个字节 CommandId uint32 //4个字节 SequenceId uint32 //4个字节 MsgId uint64 //8个字节 DestId []byte //21个字节 目的号码 ServiceId []byte //10个字节 TPPid uint8 //1个字节 TPUdhi uint8 //1个字节 MsgFmt uint8 //1个字节 SrcTerminalId []byte // 21个字节 源中断 RegisteredDelivery uint8 // 1个字节 是否为状态报告 MessageLength uint8 //1字节 内容长度 MsgContent []byte //内容长度 Reserved []byte // 8字节 保留 }
func AcquireCmppDeliver ¶
func AcquireCmppDeliver() *CmppDeliver
func (*CmppDeliver) Codec ¶
func (cdq *CmppDeliver) Codec() []byte
func (*CmppDeliver) Decodec ¶
func (cdq *CmppDeliver) Decodec(b []byte) error
cdq.MsgContent
type CmppMsgContent struct { MsgId uint64 //8个字节 Stat[]byte //7个字节 状态 SubmitTime []byte // 10个字节 提交时间 DoneTime []byte //10个字节 完成时间 DestTerminalId []byte //21个字节 SmscSequenceId uint32 //4个字节 }
func (*CmppDeliver) Fullup ¶
func (cdq *CmppDeliver) Fullup(sourceAddr, sourcePassword string)
func (*CmppDeliver) Reset ¶
func (cdq *CmppDeliver) Reset()
type CmppDeliverResp ¶
type CmppDeliverResp struct { MsgLength uint32 //4个字节 CommandId uint32 //4个字节 0x80000001 SequenceId uint32 //4个字节 MsgId uint64 //8个字节 Result uint8 //1个字节 }
func AcquireCmppDeliverResp ¶
func AcquireCmppDeliverResp() *CmppDeliverResp
func (*CmppDeliverResp) Codec ¶
func (cdr *CmppDeliverResp) Codec() []byte
func (*CmppDeliverResp) Decodec ¶
func (cdr *CmppDeliverResp) Decodec(b []byte) error
func (*CmppDeliverResp) Fullup ¶
func (cdr *CmppDeliverResp) Fullup(sequnenceId uint32, msgId uint64, result uint8)
func (*CmppDeliverResp) Reset ¶
func (cdr *CmppDeliverResp) Reset()
type CmppManager ¶
type CmppManager struct { ManagerMap map[CmppType]bool ManagerLock *sync.Mutex //ConnCount int64 GoroutinePrefix string GoroutineCount int RecordCount int64 StatisticsMap map[string]*Statistics }
var GlobalManager *CmppManager
func (*CmppManager) Response ¶
func (cm *CmppManager) Response(b []byte, writeChan chan []byte, goroutineName string)
func (*CmppManager) Summary ¶
func (cm *CmppManager) Summary()
type CmppResult ¶
type CmppResult struct { Url string `json:url` Host string `json:host` Fail int `json:fail` SubmitTime time.Time SubmitRespTime time.Time DeliverTime time.Time Error string `json:error` StatusCode int `json:status_code` DeliverCode string `json:"deliver_code"` Created string `json:created` CreatedInt int `json:created_int` }
func AcquireCmppResult ¶
func AcquireCmppResult() *CmppResult
func (*CmppResult) Fullup ¶
func (cr *CmppResult) Fullup()
func (*CmppResult) Reset ¶
func (cr *CmppResult) Reset()
type CmppSubmit ¶
type CmppSubmit struct { MsgLength uint32 //4字节 CommandId uint32 //4个字节 SequenceId uint32 //4个字节 MsgId uint64 //8字节 PkTotal uint8 //1字节 PkNumber uint8 //1字节 RegistereDelivery uint8 //1字节 MsgLevel uint8 //1字节 ServiceId []byte //10字节 业务类型 FeeUserType uint8 //1字节付费类型 FeeTerminalId []byte // 21个byte 0 TPPid uint8 //1字节 TPUdhi uint8 //1字节 MsgFmt uint8 //1字节 信息格式 MsgSrc []byte //6字节 信息内容来源 sp_id FeeType uint16 //2字节 资费类别 FeeCode []byte //6字节 资费代码 ValidTime []byte // 17字节有效期限 AtTime []byte // 17字节 定时发送 SrcId []byte //21字节 源号码 DestUserCount uint8 //1个字节 接收信息的用户数 DestTerminalId []byte //21字节 接收短信的msisdn号码 MessageLength uint8 //1个字节 信息长度 MsgContent []byte // 信息内容 Reserve []byte //8个字节保留 }
func AcquireCmppSubmit ¶
func AcquireCmppSubmit() *CmppSubmit
func (*CmppSubmit) Codec ¶
func (csq *CmppSubmit) Codec() []byte
func (*CmppSubmit) Decodec ¶
func (csq *CmppSubmit) Decodec(b []byte) error
func (*CmppSubmit) Fullup ¶
func (csq *CmppSubmit) Fullup(messageSrc string, srcId string, phone string, content string)
func (*CmppSubmit) Reset ¶
func (csq *CmppSubmit) Reset()
type CmppSubmitResp ¶
type CmppSubmitResp struct { MsgLength uint32 //4个字节 CommandId uint32 //4个字节 0x80000001 SequenceId uint32 //4个字节 MsgId []byte //8个字节 Result uint8 // 8个字节 }
func AcquireCmppSubmitResp ¶
func AcquireCmppSubmitResp() *CmppSubmitResp
func (*CmppSubmitResp) Codec ¶
func (csr *CmppSubmitResp) Codec() []byte
func (*CmppSubmitResp) Decodec ¶
func (csr *CmppSubmitResp) Decodec(b []byte) error
func (*CmppSubmitResp) Fullup ¶
func (csr *CmppSubmitResp) Fullup()
func (*CmppSubmitResp) Reset ¶
func (csr *CmppSubmitResp) Reset()
type Statistics ¶
type Statistics struct { GoroutineName string State string SubmitCount int64 SubmitRespCount int64 DeliverCount int64 BeginTime time.Time LastRecordTime time.Time LastRecordCost time.Duration Qps int64 }
color.Green(fmt.Sprintf("goroutine:%s|总共发送%v条,耗时%s|最近1000条耗时%s|平均每秒发送%v条\n", goroutineName,writeCount,time.Since(startTime).String(),time.Since(recordTime),averageCount))
func NewStatistics ¶
func NewStatistics(goroutineName string) *Statistics
Click to show internal directories.
Click to hide internal directories.