Debian Codegraph @

internal/controlproto/marshal.go

raw
1 package controlproto
2
3 import "github.com/centrifugal/centrifuge/internal/controlpb"
4
5 // Encoder ...
6 type Encoder interface {
7 EncodeCommand(*controlpb.Command) ([]byte, error)
8 EncodeNode(*controlpb.Node) ([]byte, error)
9 EncodeUnsubscribe(*controlpb.Unsubscribe) ([]byte, error)
10 EncodeDisconnect(*controlpb.Disconnect) ([]byte, error)
11 EncodeSurveyRequest(request *controlpb.SurveyRequest) ([]byte, error)
12 EncodeSurveyResponse(request *controlpb.SurveyResponse) ([]byte, error)
13 }
14
15 var _ Encoder = (*ProtobufEncoder)(nil)
16
17 // ProtobufEncoder ...
18 type ProtobufEncoder struct{}
19
20 // NewProtobufEncoder ...
21 func NewProtobufEncoder() *ProtobufEncoder {
22 return &ProtobufEncoder{}
23 }
24
25 // EncodeCommand ...
26 func (e *ProtobufEncoder) EncodeCommand(cmd *controlpb.Command) ([]byte, error) {
27 return cmd.Marshal()
28 }
29
30 // EncodeNode ...
31 func (e *ProtobufEncoder) EncodeNode(cmd *controlpb.Node) ([]byte, error) {
32 return cmd.Marshal()
33 }
34
35 // EncodeUnsubscribe ...
36 func (e *ProtobufEncoder) EncodeUnsubscribe(cmd *controlpb.Unsubscribe) ([]byte, error) {
37 return cmd.Marshal()
38 }
39
40 // EncodeDisconnect ...
41 func (e *ProtobufEncoder) EncodeDisconnect(cmd *controlpb.Disconnect) ([]byte, error) {
42 return cmd.Marshal()
43 }
44
45 // EncodeSurveyRequest ...
46 func (e *ProtobufEncoder) EncodeSurveyRequest(cmd *controlpb.SurveyRequest) ([]byte, error) {
47 return cmd.Marshal()
48 }
49
50 // EncodeSurveyRequest ...
51 func (e *ProtobufEncoder) EncodeSurveyResponse(cmd *controlpb.SurveyResponse) ([]byte, error) {
52 return cmd.Marshal()
53 }