snapshot of https://github.com/centrifugal/centrifugo.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
test / Lint (push) Failing after 3s
test / Test with Go 1.26.8 (push) Failing after 2s

This commit is contained in:
upstream-mirror
2026-09-16 01:17:21 +05:00
commit b352a9a30d
472 changed files with 108375 additions and 0 deletions

41
internal/unigrpc/codec.go Normal file
View File

@@ -0,0 +1,41 @@
package unigrpc
import (
"fmt"
"google.golang.org/protobuf/proto"
)
type rawFrame []byte
// RawCodec allows sending Protobuf encoded Pushes without
// additional wrapping and marshaling.
type RawCodec struct{}
func (c *RawCodec) Marshal(v any) ([]byte, error) {
out, ok := v.(rawFrame)
if !ok {
vv, ok := v.(proto.Message)
if !ok {
return nil, fmt.Errorf("failed to marshal, message is %T, want proto.Message", v)
}
return proto.Marshal(vv)
}
return out, nil
}
func (c *RawCodec) Unmarshal(data []byte, v any) error {
vv, ok := v.(proto.Message)
if !ok {
return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", v)
}
return proto.Unmarshal(data, vv)
}
func (c *RawCodec) String() string {
return "proto"
}
func (c *RawCodec) Name() string {
return "proto"
}