Skip to content

Commit

Permalink
A subscriptions transport coalescer
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher committed Oct 4, 2024
1 parent 859d964 commit 04d3cc9
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 460 deletions.
4 changes: 4 additions & 0 deletions packages/rpc-subscriptions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ Given an `RpcSubscriptionsChannel`, will return a new channel that parses data p
### `getRpcSubscriptionsChannelWithAutoping(channel)`

Given an `RpcSubscriptionsChannel`, will return a new channel that sends a ping message to the inner channel if a message has not been sent or received in the last `intervalMs`. In web browsers, this implementation sends no ping when the network is down, and sends a ping immediately upon the network coming back up.

### `getRpcSubscriptionsTransportWithSubscriptionCoalescing(transport)`

Given an `RpcSubscriptionsTransport`, will return a new transport that coalesces identical subscriptions into a single subscription request to the server. The determination of whether a subscription is the same as another is based on the `subscriptionConfigurationHash` returned by its `RpcSubscriptionsPlan`. The subscription will only be aborted once all subscribers abort, or there is an error.
3 changes: 2 additions & 1 deletion packages/rpc-subscriptions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
"@solana/rpc-subscriptions-channel-websocket": "workspace:*",
"@solana/rpc-subscriptions-spec": "workspace:*",
"@solana/rpc-transformers": "workspace:*",
"@solana/rpc-types": "workspace:*"
"@solana/rpc-types": "workspace:*",
"@solana/subscribable": "workspace:*"
},
"peerDependencies": {
"typescript": ">=5"
Expand Down
Loading

0 comments on commit 04d3cc9

Please sign in to comment.