https://github.com/spurge/actionqueuego
Data event stream lib and server
https://github.com/spurge/actionqueuego
event-sourcing event-stream
Last synced: 5 months ago
JSON representation
Data event stream lib and server
- Host: GitHub
- URL: https://github.com/spurge/actionqueuego
- Owner: spurge
- License: mit
- Created: 2017-02-25T20:29:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-25T20:54:20.000Z (about 9 years ago)
- Last Synced: 2024-06-20T10:22:30.117Z (almost 2 years ago)
- Topics: event-sourcing, event-stream
- Language: Go
- Size: 22.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Action Queue (go version)
=========================
[](https://semaphoreci.com/spurge/actionqueuego)
This is a very lightweight and non distributed data event stream library and server. The event stream is designed as a queue. You define you're queue with a filename (everything is written to disk) which the queue will append data to. Then you'll start adding data (Actions) to that queue. At the other end, you'll have some data consumers. Those consumers can consume any data in the stream and/or tailing.
## Setup
```bash
go get -u github.com/kardianos/govendor
govendor sync
```
## Test
`govendor test +local`
## 1. Create a queue
```go
queue, err := NewActionQueue(filename)
```
## 2. Add an action to the queue
```go
queue.AddAction("{\"some-property\":\"with-a-value\"}")
```
## 3. Read all actions
```go
callback := func(entry *ActionEntry, err error) {
// entry.pos
// entry.tim
// entry.def
}
count, err := queue.ReadHistory(callback, 0, -1)
```
## 4. Tailing actions
```go
done := make(chan bool)
callback := func(entry *ActionEntry, err error) {
// entry.pos
// entry.tim
// entry.def
}
go queue.TailHistory(callback, 0, done)
done <- true
```