func (enc *EncodeVisitor) Do(fn visitor.DoFunc) error {
	return enc.visitor.Do(func(ctx context.Context, r interface{}) error {
		msg := r.(*protocol.Message)
		rawData, err := enc.Codec.Marshal(msg)
		if err != nil {
			return err
		}
		msg.SetRawData(rawData)
		return fn(ctx, r)
	})
}
r should be PublishRequest
package adapter
import (
	"context"
	"errors"
	"github.com/silverswords/pulse/pkg/protocol"
	"github.com/silverswords/pulse/pkg/visitor"
	"strings"
)
func init() {
	RegisterCodec(&bytesCodec{})
}
var registeredCodecs = make(map[string]Codec)
func CreateCodec(name string) (Codec, error) {
	if registeredCodecs[name] != nil {
		return registeredCodecs[name], nil
	}
	return nil, errors.New("no target codec registered")
}
type EncodeVisitor struct {
	visitor visitor.Visitor
	Codec
}