-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support change event #155
Comments
This would definitely be a great addition. I don't see it coming in the next release though because there is still some groundwork to be done. |
so regarding simple way, you mean right after this line for example ? |
No, I mean by creating your own implementation wrapper. The idea is to implement the type myEngine struct {
// embed any already existing engine
// so you don't have to reimplement everything
engine.Engine
}
// override only the Begin method
func (m myEngine) Begin(w writable bool) (Transaction, error) {
tx, _ := m.Engine.Begin(w)
return &myTransaction{tx}, nil
}
type myTransaction{
// embed any already existing transaction
// so you don't have to reimplement everything
engine.Transaction
}
// override only the GetStore method
func (m myTransaction) GetStore(name []byte) (Store, error) {
st, _ = m.Transaction.GetStore(name)
return myStore{st}, nil
}
type myStore{
// embed any already existing Store
// so you don't have to reimplement everything
engine.Store
}
// now override the Put and Delete methods
func (m myTransaction) Put(k, v []byte) error {
err := m.Store.Put()
// run your trigger here
return err
}
func (m myTransaction) Delete(k []byte) error {
err := m.Store.Delete()
// run your trigger here
return err
} Then call it that way: // create first the engine of your choice (bolt, badger or memory. Here I'll choose memory)
ng := memoryengine.NewEngine()
// then wrap it with yours
myNg := myEngine{ng}
// then open a database
db, err := genji.New(&myNg) |
Right i get it now. Thanks for explaining the best way to do it. Makes sense, and very doale. I have another question that is related to this whole area of Change Event, and i think its worth visiting because its related to the way we do this. Essentially, It would be nice if genji could be used for golang projects where you also need an embedded DB that has some HA / Replication properties. SO you can stand up 3 of them in 3 different regions for example. One way to do the replication: This is cool because we can get 2 things out of the one implementation. But not sure how you feel about this, and seeking advice.... |
There is already an issue about that here #48 I guess. |
Ok fair enough, i can see your point... Is there an Issue for |
There is one for |
Thanks for update on the 2 outstanding query aggregation function of "LIKE" and "GROUP BY". Really exciting !!! In relation to change feed and my idea for doing it via a Raft like approach... https://github.com/mkawserm/flamed The standard Badger API is exposed by it. But i am still working out how best to use it with Genji. example flags:
Under the hood it uses https://github.com/lni/dragonboat
LICENSE looks liberal. |
Adding this feature to Genji would be very exciting indeed 👍 |
It would be good if I can subscribe to a change feed at the golang api level.
This will allow any higher layer to be told when a table / document changes which makes building apps on top with subscription patterns
The event just needs to say what table / document and the nature of the change which is CUD ( create, update, delete )
This is amazingly useful to build apps on top of with whatever logic an app developer needs written by themselves.
I am not sure how hard this would be and it may be not possible for all engines.
If you have any thoughts on this then it would help me scope out the required work to do it.
Also has anyone tried running this using goMonile yet? Is it envisaged as a use case.
The text was updated successfully, but these errors were encountered: