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

31
pkg/common/event.go Normal file
View File

@@ -0,0 +1,31 @@
package common
import (
"encoding/json"
"github.com/pkg/errors"
)
// Event is the generic structure for events sent over Kafka
type Event struct {
Topic string `json:"topic"`
Key string `json:"key"`
Payload Message `json:"payload"`
}
// EventRawJSON is Event (see above) but keeps payload as raw data
type EventRawJSON struct {
Topic string `json:"topic"`
Key string `json:"key"`
Payload json.RawMessage `json:"payload"`
}
func (e *EventRawJSON) Marshal() ([]byte, error) {
data, err := json.Marshal(*e)
return data, errors.WithStack(err)
}
func (e *EventRawJSON) Unmarshal(data []byte) error {
err := json.Unmarshal(data, e)
return errors.WithStack(err)
}