func (c *DubboTestCodec) EncodeRequest(request *remoting.Request) (*bytes.Buffer, error) {
	if request.Event {
		return c.encodeHeartbeartReqeust(request)
	}
	invoc, ok := request.Data.(*invocation.RPCInvocation)
	if !ok {
		return nil, perrors.Errorf("encode request failed for parameter type :%+v", request)
	}
	tmpInvocation := invoc
	svc := impl.Service{}
	svc.Path = tmpInvocation.AttachmentsByKey(constant.PATH_KEY, "")
	svc.Interface = tmpInvocation.AttachmentsByKey(constant.INTERFACE_KEY, "")
	svc.Version = tmpInvocation.AttachmentsByKey(constant.VERSION_KEY, "")
	svc.Group = tmpInvocation.AttachmentsByKey(constant.GROUP_KEY, "")
	svc.Method = tmpInvocation.MethodName()
	timeout, err := strconv.Atoi(tmpInvocation.AttachmentsByKey(constant.TIMEOUT_KEY, strconv.Itoa(constant.DEFAULT_REMOTING_TIMEOUT)))
	if err != nil {
		return nil, perrors.WithStack(err)
	}
	svc.Timeout = time.Duration(timeout)
	header := impl.DubboHeader{}
	serialization := tmpInvocation.AttachmentsByKey(constant.SERIALIZATION_KEY, constant.HESSIAN2_SERIALIZATION)
	if serialization == constant.PROTOBUF_SERIALIZATION {
		header.SerialID = constant.S_Proto
	} else {
		header.SerialID = constant.S_Hessian2
	}
	header.ID = request.ID
	if request.TwoWay {
		header.Type = impl.PackageRequest_TwoWay
	} else {
		header.Type = impl.PackageRequest
	}
	pkg := &impl.DubboPackage{
		Header:  header,
		Service: svc,
		Body:    impl.NewRequestPayload(tmpInvocation.Arguments(), tmpInvocation.Attachments()),
		Err:     nil,
		Codec:   impl.NewDubboCodec(nil),
	}
	if err := impl.LoadSerializer(pkg); err != nil {
		return nil, perrors.WithStack(err)
	}
	return pkg.Marshal()
}
encode request for transport
package getty
import (
	"bytes"
	"strconv"
	"time"
)
import (
	hessian "github.com/apache/dubbo-go-hessian2"
	perrors "github.com/pkg/errors"
)
import (
	"dubbo.apache.org/dubbo-go/v3/common/constant"
	"dubbo.apache.org/dubbo-go/v3/protocol"
	"dubbo.apache.org/dubbo-go/v3/protocol/dubbo/impl"
	"dubbo.apache.org/dubbo-go/v3/protocol/invocation"
	"dubbo.apache.org/dubbo-go/v3/remoting"
)
func init() {
	codec := &DubboTestCodec{}
	remoting.RegistryCodec("dubbo", codec)
}
type DubboTestCodec struct{}