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

[core] Introducing core-websockets #32555

Draft
wants to merge 45 commits into
base: main
Choose a base branch
from
Draft

[core] Introducing core-websockets #32555

wants to merge 45 commits into from

Conversation

deyaaeldeen
Copy link
Member

@deyaaeldeen deyaaeldeen commented Jan 14, 2025

Azure Core WebSockets Support

Overview

This pull request introduces the Azure Core WebSockets library for JavaScript. The package provides an isomorphic WebSocket client that seamlessly supports both Node.js and browser environments.

Key Contributions

  • Isomorphic Client Support:

    • The library abstracts away environment-specific details by offering unified APIs that work across Node.js and browsers.
    • Supports sending and receiving data of standard datatypes across runtimes.
  • Simplified Connection Management:

    • createWebSocketClient abstracts the complexity of connection establishment by handling URL validation, secure connection policies, and the retry and reconnection behavior to maintain connection reliability.
  • Promise-Based & Event-Driven API:

    • Consumers can either await the WebSocket connection via Promise-like interface or register event callbacks (for events like open, message, close, and error). This dual approach makes it easier to integrate with a variety of application architectures.
  • Backpressure Control:

    • Integrates a high water mark check in the send method to prevent overwhelming the send buffer.
    • If the buffered amount meets or exceeds the high water mark, a warning is logged and the send operation returns false, alerting the application to backpressure conditions.
  • Logging:

    • Detailed logging is added for every state transition, including connection attempts, successful connections, disconnections, and errors.
    • Logging has been designed to suit long-running applications by eliminating redundant logs and maintaining compactness

@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

@azure/core-websockets

Copy link
Member

@jeremymeng jeremymeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see this abstraction! I added some comments for discussion.

Copy link
Member

@xirzec xirzec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few minor comments, will need to take another look later.

attemptCount: number,
retryDelayInMs: number,
maxRetryDelayInMs: number,
mode: RetryMode,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also think about a jitter here as well instead of just the base retry delays?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants