-
Notifications
You must be signed in to change notification settings - Fork 270
feat(lazer): add ignoreInvalidFeedIds flag to SDK #2529
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
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
5 Skipped Deployments
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
lazer/sdk/js/src/protocol.ts
Outdated
@@ -47,6 +48,12 @@ export type JsonBinaryData = { | |||
data: string; | |||
}; | |||
|
|||
export type FailedFeedsDetails = { |
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.
suggest renaming this to InvalidFeedSubscriptionDetails
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
lazer/sdk/js/src/protocol.ts
Outdated
export type InvalidFeedSubscriptionDetails = { | ||
unknownIds: number[]; | ||
unsupportedChannels: number[]; | ||
comingSoon: number[]; |
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.
Keeping with the main PR, can you change this to "unstable"?
…ails Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
@@ -50,6 +52,10 @@ pub enum Response { | |||
#[serde(rename_all = "camelCase")] | |||
pub struct SubscribedResponse { | |||
pub subscription_id: SubscriptionId, | |||
#[serde(skip_serializing_if = "Option::is_none")] | |||
pub successful_feeds: Option<Vec<u64>>, |
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.
Change this to a vec of u32
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
lazer/sdk/js/src/protocol.ts
Outdated
@@ -56,6 +63,12 @@ export type Response = | |||
type: "subscribed"; | |||
subscriptionId: number; | |||
} | |||
| { | |||
type: "subscribedWithIgnoredFailures"; |
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.
Err sorry let's actually do "subscribedWithInvalidFeeds" instead.
…idFeeds Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
lazer/sdk/js/src/protocol.ts
Outdated
@@ -56,6 +63,12 @@ export type Response = | |||
type: "subscribed"; | |||
subscriptionId: number; | |||
} | |||
| { | |||
type: "subscribedWithInvalidFeeds"; |
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.
one last rename. Let's call this "subscribedWithInvalidFeedIdsIgnored".
@@ -50,6 +52,10 @@ pub enum Response { | |||
#[serde(rename_all = "camelCase")] | |||
pub struct SubscribedResponse { |
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.
SubscribedResponse should be unchanged. Add a new struct called SubscribedWithInvalidFeedIdsIgnored. It should match the new structure that is in the JS protocol.
…nvalidFeedIds Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
lazer/sdk/js/src/protocol.ts
Outdated
successfulFeeds: number[]; | ||
failedFeeds: InvalidFeedSubscriptionDetails; |
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.
Rename successfulFeeds to "subscribedFeedIds" and rename failedFeeds to "ignoredInvalidFeedIds"
pub struct SubscribedWithInvalidFeedIdsIgnoredResponse { | ||
pub subscription_id: SubscriptionId, | ||
pub successful_feeds: Vec<u32>, | ||
pub failed_feeds: serde_json::Value, |
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.
Add a struct for the failed_feeds called InvalidFeedSubscriptionDetails with the same equivalent type as the JS protocol version. Also, rename successful_feeds to "subscribed_feed_ids" and rename failed_feeds to "ignored_invalid_feed_ids".
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
@@ -40,6 +42,7 @@ pub struct UnsubscribeRequest { | |||
pub enum Response { | |||
Error(ErrorResponse), | |||
Subscribed(SubscribedResponse), | |||
SubscribedWithIgnoredInvalidFeedIds(SubscribedWithInvalidFeedIdsIgnoredResponse), |
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.
Name this "SubscribedWithInvalidFeedIdsIgnored". The response is named correctly.
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
The ignore_invalid_feed_ids field needs to be a part of the SubscriptionParams struct. |
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
@@ -358,6 +358,8 @@ pub struct SubscriptionParamsRepr { | |||
#[serde(default = "default_parsed")] | |||
pub parsed: bool, | |||
pub channel: Channel, | |||
#[serde(default)] | |||
pub ignore_invalid_feed_ids: Option<bool>, |
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.
There is no point to this being an option. Make it a bool and the serde default should default to false. Customers using the old version should submit the old SubscriptionParams struct and it should be deserialized in the Lazer service, defaulting the ignore field if not present.
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
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.
lgtm!
Yes, these are lists of feed IDs categorized by error type:
This categorization provides better customer UX by giving specific information about why each feed ID failed, rather than just a generic error. |
pub unknown_ids: Vec<u32>, | ||
pub unsupported_channels: Vec<u32>, | ||
pub unstable: Vec<u32>, |
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.
These fields should use PriceFeedId
and Channel
types.
#[serde(rename_all = "camelCase")] | ||
pub struct SubscribedWithInvalidFeedIdsIgnoredResponse { | ||
pub subscription_id: SubscriptionId, | ||
pub subscribed_feed_ids: Vec<u32>, |
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.
pub subscribed_feed_ids: Vec<u32>, | |
pub subscribed_feed_ids: Vec<PriceFeedId>, |
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
Co-Authored-By: Darun Seethammagari <darun@dourolabs.xyz>
This PR adds the ignoreInvalidFeedIds flag to the Lazer SDK to support the new feature in the Pyth Lazer router. When this flag is set to true, subscriptions will proceed with valid feeds and ignore invalid ones, returning categorized lists of successful and failed feeds.
Per user @darun Seethammagari (darun@dourolabs.xyz)'s request.
Link to Devin run: https://app.devin.ai/sessions/050e512b13ce4953bdcc8c4a2407c861