diff options
author | Valery Piashchynski <[email protected]> | 2021-05-27 13:26:12 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-05-27 13:26:12 +0300 |
commit | 0a9aea326045e56716f0736f7aa8520305362c51 (patch) | |
tree | 532ca326690d81e97136248dd798d23a56843278 /pkg/pubsub | |
parent | 57a30c2b49c36161b3af3e539a8618c2d39a5cc9 (diff) |
- Move bst to the pkg folder
- Add comments
- Fix all golangci-lint warnings
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pkg/pubsub')
-rw-r--r-- | pkg/pubsub/message.go | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/pkg/pubsub/message.go b/pkg/pubsub/message.go index ab74eb98..2536aece 100644 --- a/pkg/pubsub/message.go +++ b/pkg/pubsub/message.go @@ -6,59 +6,37 @@ import ( type Msg struct { // Topic message been pushed into. - T []string `json:"topic"` + Topics_ []string `json:"topic"` // Command (join, leave, headers) - C string `json:"command"` + Command_ string `json:"command"` // Broker (redis, memory) - B string `json:"broker"` + Broker_ string `json:"broker"` // Payload to be broadcasted - P []byte `json:"payload"` + Payload_ []byte `json:"payload"` } -//func (m Msg) UnmarshalBinary(data []byte) error { -// //Use default gob decoder -// reader := bytes.NewReader(data) -// dec := gob.NewDecoder(reader) -// if err := dec.Decode(&m); err != nil { -// return err -// } -// -// return nil -//} - func (m *Msg) MarshalBinary() ([]byte, error) { - //buf := new(bytes.Buffer) - // - //for i := 0; i < len(m.T); i++ { - // buf.WriteString(m.T[i]) - //} - // - //buf.WriteString(m.C) - //buf.WriteString(m.B) - //buf.Write(m.P) - return json.Marshal(m) - } // Payload in raw bytes func (m *Msg) Payload() []byte { - return m.P + return m.Payload_ } // Command for the connection func (m *Msg) Command() string { - return m.C + return m.Command_ } // Topics to subscribe func (m *Msg) Topics() []string { - return m.T + return m.Topics_ } func (m *Msg) Broker() string { - return m.B + return m.Broker_ } |