You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example code doesn't properly handle the case when the websocket connection fails or when the leverage update request fails with an error other than through the command failure update.
send_invalid_leverage_update_request(&auth_token).await?;// Listen to the mpsc channel for 5 seconds (for the sake of this example) to get the account// update. Normally, you would listen to this channel indefinitely to wait for messages.whileletSome(websocket_message) = receiver.recv().await{ifletAccountStreamMessage::AccountCommandFailureUpdate{payload:AccountStreamMessagePayload::AccountCommandFailureUpdate(account_command_failure_update),
..
} = websocket_message
{println!("{account_command_failure_update:#?}");}}
The example doesn't properly clean up resources. The websocket connection is never explicitly closed, and the receiver channel might not be properly drained if an error occurs.
asyncfn main() -> Result<()>{// First, we log into the desired environment.let auth_token = authenticate(Environment::Devnet).await?;// Stream websocket messages for 10 secondslet shutdown_flag = Arc::new(AtomicBool::new(false));let(sender,mut receiver) = tokio::sync::mpsc::channel::<AccountStreamMessage>(100);listen_to_command_failures(&auth_token,Environment::Devnet,
sender,Duration::from_secs(20),Arc::clone(&shutdown_flag),).await?;send_invalid_leverage_update_request(&auth_token).await?;// Listen to the mpsc channel for 5 seconds (for the sake of this example) to get the account// update. Normally, you would listen to this channel indefinitely to wait for messages.whileletSome(websocket_message) = receiver.recv().await{ifletAccountStreamMessage::AccountCommandFailureUpdate{payload:AccountStreamMessagePayload::AccountCommandFailureUpdate(account_command_failure_update),
..
} = websocket_message
{println!("{account_command_failure_update:#?}");}}
shutdown_flag.store(true, std::sync::atomic::Ordering::SeqCst);Ok(())
Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.
PR Code Suggestions ✨
Explore these optional code suggestions:
Category
Suggestion
Impact
Possible issue
Restore previous default implementation
The default implementation for AccountStreamMessage has been changed to use AccountCommandFailureUpdate instead of the previous default. This could break existing code that relies on the default being AccountOrderUpdate. Consider keeping the previous default or providing a more neutral default.
[To ensure code accuracy, apply this suggestion manually]
Suggestion importance[1-10]: 8
__
Why: This is an important suggestion that identifies a potential breaking change. Changing the default implementation from AccountOrderUpdate to AccountCommandFailureUpdate could break existing code that relies on the previous default behavior.
Medium
General
Make generator command configurable
The command has been changed from "openapi-generator" to "openapi-generator-cli", which might cause compatibility issues if users don't have the CLI version installed. Consider making this configurable or providing a fallback mechanism to support both command names.
Why: This is a good suggestion that improves flexibility by making the OpenAPI generator command configurable via an environment variable. This allows users to specify their preferred command name, supporting both the new "openapi-generator-cli" and potentially the old "openapi-generator" command.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
PR Type
Enhancement, Tests, Documentation
Description
Introduced
AccountCommandFailureUpdateto handle command failure events.AccountCommandFailureUpdatein TypeScript, Rust, and Python SDKs.AccountCommandFailureUpdatein event streams.Added example in Rust SDK for handling leverage update failures.
Updated documentation for new event types and payloads.
Changes walkthrough 📝
15 files
Added `AccountCommandFailureUpdate` interface and updated enums.Added Rust model for `AccountCommandFailureUpdate`.Updated `AccountDataStream` enum with `AccountCommandFailureUpdate`.Added `IsolatedMarginUpdated` to `AccountEventReason`.Added `AccountLeverageFailureUpdate` to `AccountEventType`.Added `AccountCommandFailureUpdate` to `AccountStreamMessage`.Added `AccountCommandFailureUpdate` to `AccountStreamMessagePayload`.Registered `AccountCommandFailureUpdate` in Rust models.Added `AccountCommandFailureUpdate` to Python SDK imports.Registered `AccountCommandFailureUpdate` in Python models.Added Python model for `AccountCommandFailureUpdate`.Updated `AccountDataStream` enum with `AccountCommandFailureUpdate`.Added `IsolatedMarginUpdated` to `AccountEventReason`.Added `AccountLeverageFailureUpdate` to `AccountEventType`.Added `AccountCommandFailureUpdate` to `AccountStreamMessagePayload`.2 files
Added example for handling leverage update failures.Added unit test for `AccountCommandFailureUpdate`.2 files
Updated OpenAPI generator command to `openapi-generator-cli`.Enforced OpenAPI generator version 7.11.0.1 files
Updated WebSocket API schema for `AccountCommandFailureUpdate`.14 files