func (r *Row) Timestamp() time.Time {
	return r.timestamp
}
Timestamp returns the row's creation timestamp.
package sieve
import (
	"encoding/json"
	"sync"
	"time"
)
func NewDB() *DB {
	return &DB{}
}
type DB struct {
	sync.Mutex
	Rows        []*Row
	subscribers []chan *Row
}
func (db *DB) Append(row *Row) {
	db.Lock()
	defer db.Unlock()
	row.index = len(db.Rows)
	row.timestamp = time.Now().UTC().Round(time.Millisecond)
	db.Rows = append(db.Rows, row)
	for _, s := range db.subscribers {
		s <- row
	}
}
func (db *DB) Row(index int) *Row {
	return db.Rows[index]
}
func (db *DB) Length() int {
	return len(db.Rows)
}
func (db *DB) Subscribe(index int) chan *Row {
	var ch = make(chan *Row, 0)
	go func() {
		for {
			db.Lock()
			var row *Row
			if index < len(db.Rows) {
				row = db.Rows[index]
				index++
			} else {
				db.subscribers = append(db.subscribers, ch)
				db.Unlock()
				break
			}
			db.Unlock()
			ch <- row
		}
	}()
	return ch
}
func (db *DB) Unsubscribe(ch chan *Row) {
	db.Lock()
	defer db.Unlock()
	for i, s := range db.subscribers {
		if s == ch {
			db.subscribers = append(db.subscribers[:i], db.subscribers[i+1:]...)
			return
		}
	}
}
type Row struct {
	Data      map[string]interface{}
	index     int
	timestamp time.Time
}
func (r *Row) Index() int {
	return r.index
}