-
Notifications
You must be signed in to change notification settings - Fork 298
feat(lazer): add history api client for symbols #3035
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
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
/// immediately from the returned receiver. | ||
/// You should continuously poll the receiver to receive updates. | ||
/// | ||
/// Panics if the buffer capacity is 0. |
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.
since we are returning a Result
let's return Err instead of panicing.
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.
Done.
println!("feeds len: {}", feeds.symbols().len()); | ||
println!("feed 1: {:?}", feeds.symbols().get(&PriceFeedId(1))); | ||
sleep(Duration::from_secs(15)).await; | ||
} |
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.
would be nice to have an example for stream too.
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.
Added.
c7cc61e
to
75c8ee1
Compare
Summary
I wasn't sure what would be the most convenient API for fetching symbol updates, so I added a few different methods:
all_symbols_metadata
- fetches only once.all_symbols_metadata_handle
- returns an ArcSwap that will be continuously updated in background. Convenient for migrating old code, but there is no way to get a notification when something changed.all_symbols_metadata_fault_tolerant_handle
- same as above, but returns an empty value if the initial fetch failed. Useful for relayer: while it needs symbols for some things, it can still work without them.all_symbols_metadata_stream
- the most flexible option: get a receiver that receives new symbols.There is also a caching feature: to avoid hard dependency on history service, we can store last known symbols locally and fetch them on startup.
Rationale
To remove
symbols.toml
and use symbols for the state-aware history service.How has this been tested?
Tested in tilt.