Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

35
pkg/common/message.go Normal file
View File

@@ -0,0 +1,35 @@
package common
import (
"encoding/json"
"github.com/pkg/errors"
)
// Message is the generic structure for messages sent over redis and kafka
type Message struct {
Handler string `json:"handler"`
Data interface{} `json:"data,omitempty"`
}
type MessageString struct {
Message string `json:"message"`
}
// MessageRawJSON is Message (see above) but keeps payload as raw data
type MessageRawJSON struct {
Handler string `json:"handler"`
Data json.RawMessage `json:"data"`
Version string `json:"version,omitempty"`
Verify string `json:"verify,omitempty"`
}
func (m *MessageRawJSON) Marshal() ([]byte, error) {
data, err := json.Marshal(*m)
return data, errors.WithStack(err)
}
func (m *MessageRawJSON) Unmarshal(data []byte) error {
err := json.Unmarshal(data, m)
return errors.WithStack(err)
}