Skip to content
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

v1.14.1 -> v1.16.0, no more *stores.EventReady event? #100

Closed
mrusme opened this issue Mar 24, 2022 · 3 comments
Closed

v1.14.1 -> v1.16.0, no more *stores.EventReady event? #100

mrusme opened this issue Mar 24, 2022 · 3 comments
Assignees

Comments

@mrusme
Copy link

mrusme commented Mar 24, 2022

I'm experiencing an issue in one of my projects, in which I've upgraded from v1.14.1 to v1.15.1 and I don't seem to be getting the *stores.EventReady event anymore from the documentstore that I'm using.

Did something change / is there a replacement for this event? Thank you.

@mrusme mrusme changed the title v1.14.1 -> v1.15.1, no more *stores.EventReady event? v1.14.1 -> v1.16.0, no more *stores.EventReady event? Mar 28, 2022
@mrusme
Copy link
Author

mrusme commented Mar 28, 2022

Just tried v1.16.0 and it's the same, the application won't start because it looks like the stores.EventReady event won't show up. I quickly checked the go-orbit-db code and it seems the event is still present. Has something else changed that would require initializing the database differently in order for it to become ready?

Appreciate any help here.

@gfanton
Copy link
Member

gfanton commented Apr 20, 2022

@mrusme sorry for the delay, i've update the event system in favor of https://github.com/libp2p/go-eventbus you should use EventBus instead of the deprecated Subscribe method. Also Events doesn't have pointer anymore, so you should update *stores.EventReady to stores.EventReady

usage example:

t.Run("loading a database emits 'ready' event", func(t *testing.T) {
defer setup(t)()
db, err := orbitdb1.Log(ctx, address.String(), nil)
require.NoError(t, err)
l := sync.RWMutex{}
var items []operation.Operation
ctx, cancel := context.WithTimeout(ctx, time.Second*5)
defer cancel()
sub, err := db.EventBus().Subscribe(new(stores.EventReady))
require.NoError(t, err)
defer sub.Close()
go func() {
for evt := range sub.Out() {
switch evt.(type) {
case stores.EventReady:
l.Lock()
items, err = db.List(ctx, &orbitdb.StreamOptions{Amount: &infinity})
l.Unlock()
cancel()
continue
}
}
}()
require.Nil(t, db.Load(ctx, infinity))
<-ctx.Done()
l.RLock()
require.Equal(t, len(items), entryCount)
require.Equal(t, string(items[0].GetValue()), "hello0")
require.Equal(t, string(items[len(items)-1].GetValue()), fmt.Sprintf("hello%d", entryCount-1))
l.RUnlock()
})

GitHub
a simple and fast eventbus for type-based local event delivery. - GitHub - libp2p/go-eventbus: a simple and fast eventbus for type-based local event delivery.

@gfanton gfanton self-assigned this Apr 20, 2022
mrusme added a commit to mrusme/superhighway84 that referenced this issue Apr 20, 2022
@mrusme
Copy link
Author

mrusme commented Apr 20, 2022

Thank you, that was the info I needed. Upgrade has worked and the EventReady event is now firing. Appreciate it!

@mrusme mrusme closed this as completed Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants