flumedb

模块化数据库,日志随流而动。(modular database where logs are moved with streams)

  • 所有者: flumedb/flumedb
  • 平台: Linux, Mac, Windows
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

flumedb

A modular database made for moving logs with streams.

architecture

Flume is a modular database comprised of an Append Only Log
and Streaming Views on that log.
This makes a star shaped pipeline - or rather, there is a pipeline
from the log to each view, but the log is part of every pipeline.

The Log is the main storage element and provides durability.
Views stream that data and build up their own model. They
can point back to the main storage (normalized) or materialize it
(denormalized). The views can use a structure optimized for
the queries they provide, instead of durability, because the
can rebuild from the main log.

In my previous modular database design, level-sublevel
indexes had to be written atomically with the data. This was
okay for map style indexes, but made simple aggregations such
as a count of all records difficult. Worse, rebuilding the indexes
needed a batch migration between two versions of the database.
This made developing interesting applications on level-sublevel quite difficult (such as secure-scuttlebutt)

In flume, each view remembers a version number, and if the version
number changes, it just rebuilds the view. This means view code can
be easily updated, or new views added. It just rebuilds the view on
startup. (though, this may take a few minutes on larger data)

The trick is that each view exposes a observable, flumeview.since,
this represents it's current state - the sequence number the view is up to.
An observable is like an event meets a value. it's an changing value that you can observe.
Events, promises, or streams are similar, but not quite the right choice here.

Note, views are async. The main log may callback before the view is
fully up to date, but if a read is made to an as yet unsynced view,
it just waits for the view building to complete. This may make
the call take longer (applications should show a progress bar
for reindexing) but most of the application code can just assume
that indexes are always up to date, because if you get a callback
from an append to the log, a subsequent view read will return
data consistent with that.

This gives us the freedom to have async views,
which gives us the freedom to have many different sorts of views!

example

Take one flumelog-* module and zero or more flumeview-* modules,
and glue them together with flumedb.

var MemLog = require('flumelog-memory') // just store the log in memory
var Reduce = require('flumeview-reduce') //just a reduce function.
var Flume = require('flumedb')

var db = Flume(MemLog())
  //the api of flumeview-reduce will be mounted at db.sum...
  .use('sum', Reduce(1, function (acc, item) {
    return (acc

主要指标

概览
名称与所有者flumedb/flumedb
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台Linux, Mac, Windows
许可证MIT License
所有者活动
创建于2016-11-03 22:16:12
推送于2021-08-11 00:41:55
最后一次提交2020-06-18 15:24:15
发布数21
最新版本名称v2.1.8 (发布于 2020-06-18 15:24:15)
第一版名称v0.4.7 (发布于 2018-06-04 11:26:10)
用户参与
星数258
关注者数8
派生数16
提交数200
已启用问题?
问题数16
打开的问题数4
拉请求数27
打开的拉请求数1
关闭的拉请求数7
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?