|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773 |
- package codec
-
- import (
- "bytes"
- "github.com/dk-lockdown/seata-golang/meta"
- "github.com/dk-lockdown/seata-golang/protocal"
- "vimagination.zapto.org/byteio"
- )
-
- func AbstractResultMessageDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.AbstractResultMessage{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
- resultCode, _ := r.ReadByte()
- msg.ResultCode = protocal.ResultCode(resultCode)
- totalReadN += 1
- if msg.ResultCode == protocal.ResultCodeFailed {
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Msg, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
- }
-
- return msg,totalReadN
- }
-
- func MergedWarpMessageDecoder(in []byte) (interface{},int) {
- var (
- size16 int16 = 0
- readN = 0
- totalReadN = 0
- )
- result := protocal.MergedWarpMessage{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
-
- r.ReadInt32()
- totalReadN += 4
- size16,readN,_ = r.ReadInt16()
- totalReadN += readN
- result.Msgs = make([]protocal.MessageTypeAware,0)
- for index := 0; index < int(size16); index++ {
- typeCode,_,_ := r.ReadInt16()
- totalReadN += 2
- decoder := getMessageDecoder(typeCode)
- if decoder != nil {
- msg,readN := decoder(in[totalReadN:])
- totalReadN += readN
- result.Msgs = append(result.Msgs,msg.(protocal.MessageTypeAware))
- }
- }
- return result,totalReadN
- }
-
- func MergeResultMessageDecoder(in []byte) (interface{},int) {
- var (
- size16 int16 = 0
- readN = 0
- totalReadN = 0
- )
- result := protocal.MergeResultMessage{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
-
- r.ReadInt32()
- totalReadN += 4
- size16,readN,_ = r.ReadInt16()
- totalReadN += readN
- result.Msgs = make([]protocal.MessageTypeAware,0)
-
- for index := 0; index < int(size16); index++ {
- typeCode,_,_ := r.ReadInt16()
- totalReadN += 2
- decoder := getMessageDecoder(typeCode)
- if decoder != nil {
- msg,readN := decoder(in[totalReadN:])
- totalReadN += readN
- result.Msgs = append(result.Msgs,msg.(protocal.MessageTypeAware))
- }
- }
- return result,totalReadN
- }
-
- func AbstractIdentifyRequestDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.AbstractIdentifyRequest{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Version, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ApplicationId, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.TransactionServiceGroup, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ExtraData = make([]byte,int(length16))
- readN, _ := r.Read(msg.ExtraData)
- totalReadN += readN
- }
-
- return msg,totalReadN
- }
-
- func AbstractIdentifyResponseDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.AbstractIdentifyResponse{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
-
- identified, _ := r.ReadByte()
- totalReadN += 1
- if identified == byte(1){
- msg.Identified = true
- } else if identified == byte(0) {
- msg.Identified = false
- }
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Version, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- return msg,totalReadN
- }
-
- func RegisterRMRequestDecoder(in []byte) (interface{},int) {
- var (
- length32 uint32 = 0
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.RegisterRMRequest{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Version, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ApplicationId, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.TransactionServiceGroup, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ExtraData = make([]byte,int(length16))
- readN, _ := r.Read(msg.ExtraData)
- totalReadN += readN
- }
-
- length32, readN, _ = r.ReadUint32()
- totalReadN += readN
- if length32 > 0 {
- msg.ResourceIds, readN, _ = r.ReadString(int(length32))
- totalReadN += readN
- }
-
- return msg,totalReadN
- }
-
- func RegisterRMResponseDecoder(in []byte) (interface{},int) {
- resp,totalReadN := AbstractIdentifyResponseDecoder(in)
- abstractIdentifyResponse := resp.(protocal.AbstractIdentifyResponse)
- msg := protocal.RegisterRMResponse{AbstractIdentifyResponse:abstractIdentifyResponse}
- return msg,totalReadN
- }
-
- func RegisterTMRequestDecoder(in []byte) (interface{},int) {
- req,totalReadN := AbstractIdentifyRequestDecoder(in)
- abstractIdentifyRequest := req.(protocal.AbstractIdentifyRequest)
- msg := protocal.RegisterTMRequest{AbstractIdentifyRequest:abstractIdentifyRequest}
- return msg,totalReadN
- }
-
- func RegisterTMResponseDecoder(in []byte) (interface{},int) {
- resp,totalReadN := AbstractIdentifyResponseDecoder(in)
- abstractIdentifyResponse := resp.(protocal.AbstractIdentifyResponse)
- msg := protocal.RegisterRMResponse{AbstractIdentifyResponse:abstractIdentifyResponse}
- return msg,totalReadN
- }
-
- func AbstractTransactionResponseDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.AbstractTransactionResponse{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
- resultCode, _ := r.ReadByte()
- totalReadN += 1
- msg.ResultCode = protocal.ResultCode(resultCode)
- if msg.ResultCode == protocal.ResultCodeFailed {
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Msg, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
- }
-
- exceptionCode, _ := r.ReadByte()
- totalReadN += 1
- msg.TransactionExceptionCode = meta.TransactionExceptionCode(exceptionCode)
-
- return msg,totalReadN
- }
-
- func AbstractBranchEndRequestDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.AbstractBranchEndRequest{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Xid, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- msg.BranchId, _, _ = r.ReadInt64()
- totalReadN += 8
- branchType, _ := r.ReadByte()
- totalReadN += 1
- msg.BranchType = meta.BranchType(branchType)
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ResourceId, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ApplicationData = make([]byte,int(length16))
- readN,_ := r.Read(msg.ApplicationData)
- totalReadN += readN
- }
-
- return msg,totalReadN
- }
-
- func AbstractBranchEndResponseDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.AbstractBranchEndResponse{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
- resultCode, _ := r.ReadByte()
- totalReadN += 1
- msg.ResultCode = protocal.ResultCode(resultCode)
- if msg.ResultCode == protocal.ResultCodeFailed {
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Msg, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
- }
-
- exceptionCode, _ := r.ReadByte()
- totalReadN += 1
- msg.TransactionExceptionCode = meta.TransactionExceptionCode(exceptionCode)
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Xid, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- msg.BranchId, _, _ = r.ReadInt64()
- totalReadN += 8
- branchStatus,_ := r.ReadByte()
- totalReadN += 1
- msg.BranchStatus = meta.BranchStatus(branchStatus)
-
- return msg,totalReadN
- }
-
- func AbstractGlobalEndRequestDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.AbstractGlobalEndRequest{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Xid, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ExtraData = make([]byte,int(length16))
- readN,_ := r.Read(msg.ExtraData)
- totalReadN += readN
- }
-
- return msg,totalReadN
- }
-
- func AbstractGlobalEndResponseDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.AbstractGlobalEndResponse{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
- resultCode, _ := r.ReadByte()
- totalReadN += 1
- msg.ResultCode = protocal.ResultCode(resultCode)
- if msg.ResultCode == protocal.ResultCodeFailed {
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Msg, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
- }
-
- exceptionCode, _ := r.ReadByte()
- totalReadN += 1
- msg.TransactionExceptionCode = meta.TransactionExceptionCode(exceptionCode)
-
- globalStatus,_ := r.ReadByte()
- totalReadN += 1
- msg.GlobalStatus = meta.GlobalStatus(globalStatus)
-
- return msg,totalReadN
- }
-
- func BranchCommitRequestDecoder(in []byte) (interface{},int) {
- req,totalReadN := AbstractBranchEndRequestDecoder(in)
- abstractBranchEndRequest := req.(protocal.AbstractBranchEndRequest)
- msg := protocal.BranchCommitRequest{AbstractBranchEndRequest:abstractBranchEndRequest}
- return msg,totalReadN
- }
-
- func BranchCommitResponseDecoder(in []byte) (interface{},int) {
- resp,totalReadN := AbstractBranchEndResponseDecoder(in)
- abstractBranchEndResponse := resp.(protocal.AbstractBranchEndResponse)
- msg := protocal.BranchCommitResponse{AbstractBranchEndResponse:abstractBranchEndResponse}
- return msg,totalReadN
- }
-
- func BranchRegisterRequestDecoder(in []byte) (interface{},int) {
- var (
- length32 uint32 = 0
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.BranchRegisterRequest{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Xid, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- branchType, _ := r.ReadByte()
- totalReadN += 1
- msg.BranchType = meta.BranchType(branchType)
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ResourceId, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- length32, readN, _ = r.ReadUint32()
- totalReadN += readN
- if length32 > 0 {
- msg.LockKey, readN, _ = r.ReadString(int(length32))
- totalReadN += readN
- }
-
- length32, readN, _ = r.ReadUint32()
- totalReadN += readN
- if length32 > 0 {
- msg.ApplicationData = make([]byte,int(length32))
- readN,_ := r.Read(msg.ApplicationData)
- totalReadN += readN
- }
-
- return msg,totalReadN
- }
-
- func BranchRegisterResponseDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.BranchRegisterResponse{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
- resultCode, _ := r.ReadByte()
- totalReadN += 1
- msg.ResultCode = protocal.ResultCode(resultCode)
- if msg.ResultCode == protocal.ResultCodeFailed {
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Msg, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
- }
-
- exceptionCode, _ := r.ReadByte()
- totalReadN += 1
- msg.TransactionExceptionCode = meta.TransactionExceptionCode(exceptionCode)
-
- msg.BranchId, readN, _ = r.ReadInt64()
- totalReadN += readN
-
- return msg,totalReadN
- }
-
- func BranchReportRequestDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.BranchReportRequest{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Xid, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- msg.BranchId, _, _ = r.ReadInt64()
- branchStatus, _ := r.ReadByte()
- msg.Status = meta.BranchStatus(branchStatus)
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ResourceId, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ApplicationData = make([]byte,int(length16))
- readN,_ := r.Read(msg.ApplicationData)
- totalReadN += readN
- }
-
- branchType, _ := r.ReadByte()
- totalReadN += 1
- msg.BranchType = meta.BranchType(branchType)
-
- return msg,totalReadN
- }
-
- func BranchReportResponseDecoder(in []byte) (interface{},int) {
- resp,totalReadN := AbstractTransactionResponseDecoder(in)
- abstractTransactionResponse := resp.(protocal.AbstractTransactionResponse)
- msg := protocal.BranchReportResponse{AbstractTransactionResponse: abstractTransactionResponse}
- return msg,totalReadN
- }
-
- func BranchRollbackRequestDecoder(in []byte) (interface{},int) {
- req,totalReadN := AbstractBranchEndRequestDecoder(in)
- abstractBranchEndRequest := req.(protocal.AbstractBranchEndRequest)
- msg := protocal.BranchRollbackRequest{AbstractBranchEndRequest:abstractBranchEndRequest}
- return msg,totalReadN
- }
-
- func BranchRollbackResponseDecoder(in []byte) (interface{},int) {
- resp,totalReadN := AbstractBranchEndResponseDecoder(in)
- abstractBranchEndResponse := resp.(protocal.AbstractBranchEndResponse)
- msg := protocal.BranchRollbackResponse{AbstractBranchEndResponse:abstractBranchEndResponse}
- return msg,totalReadN
- }
-
- func GlobalBeginRequestDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.GlobalBeginRequest{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
-
- timeout, readN, _ := r.ReadInt32()
- totalReadN += readN
- msg.Timeout = timeout
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.TransactionName, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- return msg,totalReadN
- }
-
- func GlobalBeginResponseDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.GlobalBeginResponse{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
- resultCode, _ := r.ReadByte()
- totalReadN += 1
- msg.ResultCode = protocal.ResultCode(resultCode)
- if msg.ResultCode == protocal.ResultCodeFailed {
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Msg, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
- }
-
- exceptionCode, _ := r.ReadByte()
- totalReadN += 1
- msg.TransactionExceptionCode = meta.TransactionExceptionCode(exceptionCode)
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Xid, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ExtraData = make([]byte,int(length16))
- readN,_ := r.Read(msg.ExtraData)
- totalReadN += readN
- }
-
- return msg,totalReadN
- }
-
- func GlobalCommitRequestDecoder(in []byte) (interface{},int) {
- req,totalReadN := AbstractGlobalEndRequestDecoder(in)
- abstractGlobalEndRequest := req.(protocal.AbstractGlobalEndRequest)
- msg := protocal.GlobalCommitRequest{AbstractGlobalEndRequest:abstractGlobalEndRequest}
- return msg,totalReadN
- }
-
- func GlobalCommitResponseDecoder(in []byte) (interface{},int) {
- resp,totalReadN := AbstractGlobalEndResponseDecoder(in)
- abstractGlobalEndResponse := resp.(protocal.AbstractGlobalEndResponse)
- msg := protocal.GlobalCommitResponse{AbstractGlobalEndResponse:abstractGlobalEndResponse}
- return msg,totalReadN
- }
-
- func GlobalLockQueryRequestDecoder(in []byte) (interface{},int) {
- req,totalReadN := BranchRegisterRequestDecoder(in)
- branchRegisterRequest := req.(protocal.BranchRegisterRequest)
- msg := protocal.GlobalLockQueryRequest{BranchRegisterRequest:branchRegisterRequest}
- return msg,totalReadN
- }
-
- func GlobalLockQueryResponseDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.GlobalLockQueryResponse{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
- resultCode, _ := r.ReadByte()
- totalReadN += 1
- msg.ResultCode = protocal.ResultCode(resultCode)
- if msg.ResultCode == protocal.ResultCodeFailed {
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Msg, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
- }
-
- exceptionCode, _ := r.ReadByte()
- totalReadN += 1
- msg.TransactionExceptionCode = meta.TransactionExceptionCode(exceptionCode)
-
- lockable, readN, _ := r.ReadUint16()
- totalReadN += readN
- if lockable == uint16(1) {
- msg.Lockable = true
- } else if lockable == uint16(0) {
- msg.Lockable = false
- }
-
- return msg,totalReadN
- }
-
- func GlobalReportRequestDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.GlobalReportRequest{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.Xid, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ExtraData = make([]byte,int(length16))
- readN, _ := r.Read(msg.ExtraData)
- totalReadN += readN
- }
-
- globalStatus,_ := r.ReadByte()
- totalReadN += 1
- msg.GlobalStatus = meta.GlobalStatus(globalStatus)
-
- return msg,totalReadN
- }
-
- func GlobalReportResponseDecoder(in []byte) (interface{},int) {
- resp,totalReadN := AbstractGlobalEndResponseDecoder(in)
- abstractGlobalEndResponse := resp.(protocal.AbstractGlobalEndResponse)
- msg := protocal.GlobalReportResponse{AbstractGlobalEndResponse:abstractGlobalEndResponse}
- return msg,totalReadN
- }
-
- func GlobalRollbackRequestDecoder(in []byte) (interface{},int) {
- req,totalReadN := AbstractGlobalEndRequestDecoder(in)
- abstractGlobalEndRequest := req.(protocal.AbstractGlobalEndRequest)
- msg := protocal.GlobalRollbackRequest{AbstractGlobalEndRequest:abstractGlobalEndRequest}
- return msg,totalReadN
- }
-
- func GlobalRollbackResponseDecoder(in []byte) (interface{},int) {
- resp,totalReadN := AbstractGlobalEndResponseDecoder(in)
- abstractGlobalEndResponse := resp.(protocal.AbstractGlobalEndResponse)
- msg := protocal.GlobalRollbackResponse{AbstractGlobalEndResponse:abstractGlobalEndResponse}
- return msg,totalReadN
- }
-
- func GlobalStatusRequestDecoder(in []byte) (interface{},int) {
- req,totalReadN := AbstractGlobalEndRequestDecoder(in)
- abstractGlobalEndRequest := req.(protocal.AbstractGlobalEndRequest)
- msg := protocal.GlobalStatusRequest{AbstractGlobalEndRequest:abstractGlobalEndRequest}
- return msg,totalReadN
- }
-
- func GlobalStatusResponseDecoder(in []byte) (interface{},int) {
- resp,totalReadN := AbstractGlobalEndResponseDecoder(in)
- abstractGlobalEndResponse := resp.(protocal.AbstractGlobalEndResponse)
- msg := protocal.GlobalStatusResponse{AbstractGlobalEndResponse:abstractGlobalEndResponse}
- return msg,totalReadN
- }
-
- func UndoLogDeleteRequestDecoder(in []byte) (interface{},int) {
- var (
- length16 uint16 = 0
- readN = 0
- totalReadN = 0
- )
- msg := protocal.UndoLogDeleteRequest{}
-
- r := byteio.BigEndianReader{Reader:bytes.NewReader(in)}
- branchType, _ := r.ReadByte()
- totalReadN += 1
- msg.BranchType = meta.BranchType(branchType)
-
- length16, readN, _ = r.ReadUint16()
- totalReadN += readN
- if length16 > 0 {
- msg.ResourceId, readN, _ = r.ReadString(int(length16))
- totalReadN += readN
- }
-
- msg.SaveDays, readN, _ = r.ReadInt16()
- totalReadN += readN
-
- return msg,totalReadN
- }
|