var EventStoreDB *sql.DB
func SetEventStoreDB(psqlInfo string)
Setting database connection
type Dispatcher map[string]func(*map[string]any) (map[string]interface{}, error)
type Event struct {
Id string
Projection any
Args map[string]any
}
func NewEvent(projection any, args map[string]any) Event
Event constructor
type EventStore struct {
Dispatcher *Dispatcher
Done chan bool
Wg sync.WaitGroup
// contains filtered or unexported fields
}
func NewEventStore(dispatcher *Dispatcher) *EventStore
Eventstore constructor
func (eventstore *EventStore) Broadcast() error
Broadcasts every published event
func (eventstore *EventStore) GetEvent() any
Get event from sync.Pool
func (eventstore *EventStore) Publish(event Event)
Subscribing event
func (eventstore *EventStore) Query(projection string) map[string](map[string]any)
querying database for events of projections'
func (eventstore *EventStore) Run()
func (eventstore *EventStore) Setup(dbname string)
Setting up database and creating table
type EventStoreListener struct {
OnDescription chan string
OnBye chan bool
}
type EventStoreNode struct {
Listner EventStoreListener
DC webrtc.DataChannel
// contains filtered or unexported fields
}
func NewEventStoreNode(dispatcher Dispatcher) *EventStoreNode
EventStoreNode constructor
func (eventstore *EventStoreNode) HandleDataChannel(id string, event *Event)
func (eventstore *EventStoreNode) Publish(event string)
Sending bytes over datachannels to publish events and send it in database Serializing data before inserting it to database
func (eventstore *EventStoreNode) Subscribe(event Event)
Usecase of datachannel, event is encoded into bytes and send to another peer (look into Publish func)
type Serializer struct {
// contains filtered or unexported fields
}
func NewSerializer() *Serializer
Serializer constructor
func (serializer *Serializer) Deserialize(data []byte) map[string]any
Deserialize deserializes data []byte to map[string]any
func (serializer *Serializer) Serialize(data map[string]any) []byte
Serialize serializes data into []byte