-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
(WIP) Kappa5 #13
(WIP) Kappa5 #13
Conversation
This is a dependency-free version of the kappa core idea. It connects sources to views and tracks state. Next commit will add a kappaClassic wrapper that support multifeed by default.
Also removes a "parent flow" leftover of the removed subflows pattern.
This is super cool @Frando. I'm still thinking through everything, but here are some initial questions:
var kappa = require('kappa-core')
var hsource = require('kappa-source-hypercore')
var tinybox = require('tinybox')
var raf = require('random-access-file')
var bkdview = require('kappa-view-bkd')
var level = require('level')
var core = kappa()
var src = hsource(tinybox(raf)) // stores `version` and `state` in a random-access-* store
var view = bkdview(level('./foo')) // store just the spatial database details
core.use('spatial', src, view) // hooks up the source and view instances
core.api.spatial.query([-40,40,-80,80], (err, res) => { /*...*/ }) |
btw, kappa-core is on |
So, now in some more words. I agree to noffle's remarks!
I started to update the Kappa5 based on these observations. Before I continue I think I'd like for us to agree on the end result so that its not too much work rewriting things again. Currently, a most simple example would look like this: https://gist.github.com/Frando/21bc9e796544692b51de7e85edd1983a Things to note:
|
I started upating the API after the discussions. See https://github.com/Frando/kappa-core/tree/kappa5-new for now. Most tests are updated and pass. |
This is continued in #14. |
This PR pulls in the current state of my kappa5 branch. It has been talked about a bit already: It changes kappa-core to be dependency-free (it just connects sources to views) which should make it much easier to support flexible indexing flows and scenarios. And then it includes sources for hypercore and multifeed (and hyperdrives!).
This is not completely ready yet i think, but I wanted to put it up for review and discussion, and to agree on the best way on.
README with the new API
Open questions and missing features
State handling. In current kappa, the views need to provide storeState/fetchState handlers if they want to persist the indexer's state. I don't think this should stay with the view, as now a view can have many sources. There's two parts of state here: 1) the view version to trigger a rebuild on a version change 2) the indexing progress. For 2) a more complex (sparse) indexer/source would track the progress on its own (eg in bitfields), a simple source could still make use of a buffer to store its state.
So my current thinking is: Have the kappa track the state for view versions, and a buffer per flow (source instance-view combo), by default in-memory. And allow to supply
storeState (key, state, cb)
,fetchState (key, cb)
opts to the kappa-core. We could then also ship eg a simple implementation with tinybox, then only a random-access-storage instance would have to be passed into the kappa for persistence.Naming: do people like the
source
term here? I was thinking ifindexer
would be better, but am not sure. Like, thecreateSource
function does create a source for the kappa, which usually is a function that indexes a set of feeds or other datastructures. So creating a source for the kappa does usually not create datastructures, but only the function that indexes them.Backwards compatibility: Currently there is the
kappaClassic
function inindex.js
that wires the new kappa-core together in an API-compatible way to the current kappa-core. I mostly did this for testing - it passes thecabal-core
tests. However, this is based on current multifeed, which means hypercore 7. So actually, I'd propose to not have that, and have a backwards incompatible change.What to include in kappa-core? Should
kappa-core
be just the kappa-core, or also include a set of useful sources? (the modules in/sources
)