1234567891011121314151617181920212223242526272829 |
- package borealis
- import (
- "encoding/json"
- "reflect"
- "time"
- "github.com/segmentio/ksuid"
- )
- type Event[T any] struct {
- Type EventType `json:"type,string"`
- SequentialID uint64 `json:"sequential_id"`
- Timestamp time.Time `json:"timestamp"`
- UniqueID ksuid.KSUID `json:"unique_id"`
- Payload T `json:"payload"`
- }
- func (event Event[T]) Equal(other Event[T]) bool {
- return reflect.DeepEqual(event, other)
- }
- func (event Event[T]) JSON() string {
- output, err := json.Marshal(event)
- if err != nil {
- panic(err)
- }
- return string(output)
- }
|