github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/docs/v2/design/framework/events.md (about) 1 # Events 2 3 Micro events is a timeseries database for event streaming 4 5 ## Overview 6 7 Micro has the concepts of key-value storage through the Store interface and asynchronous messaging 8 through the Broker interface. These things individually are useful but often we're looking for 9 something more. Essentially a timeseries based event stream of data thats persistent. 10 11 ## Design 12 13 We always start with: 14 15 - Go Micro interface 16 * Zero dep implementation 17 * Distributed system equivalent 18 * Service implementation 19 20 Our goal is to define a go-micro/event package with Event interface that supports reading and writing 21 events and being able to playback from a specific Offset which is a timestamp. The first attempt 22 at this was file based style [sync/event](https://github.com/micro/go-micro/blob/master/sync/event/event.go). 23 24 ``` 25 // Event provides a distributed log interface 26 type Event interface { 27 // Log retrieves the log with an id/name 28 Log(id string) (Log, error) 29 } 30 31 // Log is an individual event log 32 type Log interface { 33 // Close the log handle 34 Close() error 35 // Log ID 36 Id() string 37 // Read will read the next record 38 Read() (*Record, error) 39 // Go to an offset 40 Seek(offset int64) error 41 // Write an event to the log 42 Write(*Record) error 43 } 44 45 type Record struct { 46 Metadata map[string]interface{} 47 Data []byte 48 } 49 ``` 50 51 We probably want something similar but new ideas are welcome. 52 53 ## Service 54 55 After the interface has been implemented (which acts as a building block) we want to build 56 the service equivalent. The service will effectively provide an RPC interface for event 57 streaming based on our go-micro interface. 58 59 Ideally we're writing a stream of events to a database where keys are timeseries with 60 key-prefix:timestamp (truncated to hour or configurable). 61 62 Timeseries ontop of cassandra as example [cassandra/timeseries](https://github.com/HailoOSS/service/tree/master/cassandra/timeseries) 63 64