message driver storage

This commit is contained in:
bel
2024-04-11 22:23:17 -06:00
parent b39b5a66e7
commit def095e0e8
7 changed files with 166 additions and 0 deletions

37
message.go Normal file
View File

@@ -0,0 +1,37 @@
package main
import "encoding/json"
type Message struct {
ID string
TS uint64
Plain string
Source string
Channel string
Thread string
EventName string
EventID string
AssetID string
}
func (m Message) Serialize() []byte {
b, err := json.Marshal(m)
if err != nil {
panic(err)
}
return b
}
func MustDeserialize(b []byte) Message {
m, err := Deserialize(b)
if err != nil {
panic(err)
}
return m
}
func Deserialize(b []byte) (Message, error) {
var m Message
err := json.Unmarshal(b, &m)
return m, err
}