File tree Expand file tree Collapse file tree 3 files changed +21
-21
lines changed
Expand file tree Collapse file tree 3 files changed +21
-21
lines changed Original file line number Diff line number Diff line change 1- class WebSocketConnectionManager < ApplicationController
2- def token
3- token = StreamingTokenService . get
4- payload = StreamingTokenService . payload
5- render json : {
6- token : token ,
7- expires_at : payload &.dig ( :expires_at )
8- }
9- end
10-
11- private
12-
13- def get_oauth_token
14- StreamingTokenService . get
15- end
1+ class WebsocketSubscriptionsController < ApplicationController
2+ def token
3+ token = StreamingTokenService . get
4+ payload = StreamingTokenService . payload
5+ render json : {
6+ token : token ,
7+ expires_at : payload &.dig ( :expires_at )
8+ }
9+ end
10+
11+ private
12+
13+ def get_oauth_token
14+ StreamingTokenService . get
1615 end
16+ end
1717
1818 # def get_streaming_access_token
1919 # url = URI("https://oauth2.bitquery.io/oauth2/token")
Original file line number Diff line number Diff line change 1- class WebSocketConnectionManager
1+ class WebsocketConnectionManager
22 MAX_CONNECTIONS = ENV . fetch ( 'WEBSOCKET_MAX_CONNECTIONS' , '100' ) . to_i
33 CONNECTION_TIMEOUT = ENV . fetch ( 'WEBSOCKET_CONNECTION_TIMEOUT_MINUTES' , '5' ) . to_i . minutes
44
Original file line number Diff line number Diff line change 11Rails . application . config . after_initialize do
22 at_exit do
3- if defined? ( ::WebSocketConnectionManager )
3+ if defined? ( ::WebsocketConnectionManager )
44 Rails . logger . info "Shutting down WebSocket connection manager..."
5- ::WebSocketConnectionManager . instance . shutdown rescue nil
5+ ::WebsocketConnectionManager . instance . shutdown rescue nil
66 end
77 end
88
99 Thread . new do
1010 loop do
1111 sleep 60
1212 begin
13- if defined? ( ::WebSocketConnectionManager )
14- ::WebSocketConnectionManager . instance . cleanup_expired_connections
15- Rails . logger . debug "WebSocket connection cleanup complete. Active connections: #{ ::WebSocketConnectionManager . instance . active_connections_count } "
13+ if defined? ( ::WebsocketConnectionManager )
14+ ::WebsocketConnectionManager . instance . cleanup_expired_connections
15+ Rails . logger . debug "WebSocket connection cleanup complete. Active connections: #{ ::WebsocketConnectionManager . instance . active_connections_count } "
1616 end
1717 rescue => e
1818 Rails . logger . error "Error in WebSocket connection cleanup: #{ e . message } "
You can’t perform that action at this time.
0 commit comments