-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
chore: events: implement event observer deregister method #8441
Conversation
chain/events/observer.go
Outdated
observers []TipSetObserver | ||
|
||
observerID uint64 | ||
observers map[uint64]TipSetObserver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some things may care about the order this map in iterated in (mostly tests tho)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could make a TipSetObservers
type and implement an iterator pattern over it for consistent ordering, would that work? Something like:
for observers.HasNext() {
if err := observers.Next().Revert(ctx, from, to); err != nil {
log.Errorf("observer %T failed to apply tipset %s (%d) with: %s", obs, from.Key(), from.Height(), err)
}
}
ea40ba6
to
5c009c3
Compare
Codecov Report
@@ Coverage Diff @@
## master #8441 +/- ##
==========================================
- Coverage 40.66% 40.62% -0.04%
==========================================
Files 686 686
Lines 75398 75409 +11
==========================================
- Hits 30661 30636 -25
- Misses 39443 39461 +18
- Partials 5294 5312 +18
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems complicated and expensive. Given that adding/removing observers is rare, can we notadd a Deregister
method that:
- Takes the same
TipSetObserver
interface. - Compares by-pointer with all elements in the observer list to find the observer to remove.
- Creates a new list without that observer?
Do you need observer "IDs"?
Here's a sketch: #8445 |
Agreed, its a bit complicated to maintain consistent ordering with this approach. Yeah passing the TipSetObserver interface to an unregister method will work for Lily's use case, thanks for the sketch. |
81ae68e
to
fbda4e0
Compare
fbda4e0
to
20bf46f
Compare
Related Issues
Lily schedles jobs that use the events system to observe head changes. When these jobs exit their observer needs to be deregistered from the events system. Currently this is not possible, this PR addresses this.
Proposed Changes
Allow event observers to be deregistered
Checklist
Before you mark the PR ready for review, please make sure that:
<PR type>: <area>: <change being made>
fix: mempool: Introduce a cache for valid signatures
PR type
: fix, feat, INTERFACE BREAKING CHANGE, CONSENSUS BREAKING, build, chore, ci, docs,perf, refactor, revert, style, testarea
: api, chain, state, vm, data transfer, market, mempool, message, block production, multisig, networking, paychan, proving, sealing, wallet, deps