@cratis/arc 19.12.0 → 20.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Globals.ts +20 -1
- package/dist/cjs/Globals.d.ts +4 -0
- package/dist/cjs/Globals.d.ts.map +1 -1
- package/dist/cjs/Globals.js +6 -1
- package/dist/cjs/Globals.js.map +1 -1
- package/dist/cjs/queries/HubConnectionKeepAlive.d.ts +11 -0
- package/dist/cjs/queries/HubConnectionKeepAlive.d.ts.map +1 -0
- package/dist/cjs/queries/HubConnectionKeepAlive.js +33 -0
- package/dist/cjs/queries/HubConnectionKeepAlive.js.map +1 -0
- package/dist/cjs/queries/IObservableQueryHubConnection.d.ts +11 -0
- package/dist/cjs/queries/IObservableQueryHubConnection.d.ts.map +1 -0
- package/dist/cjs/queries/IReconnectPolicy.d.ts +8 -0
- package/dist/cjs/queries/IReconnectPolicy.d.ts.map +1 -0
- package/dist/cjs/queries/ObservableQueryConnection.d.ts +3 -1
- package/dist/cjs/queries/ObservableQueryConnection.d.ts.map +1 -1
- package/dist/cjs/queries/ObservableQueryConnection.js +8 -21
- package/dist/cjs/queries/ObservableQueryConnection.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryConnectionFactory.d.ts +13 -0
- package/dist/cjs/queries/ObservableQueryConnectionFactory.d.ts.map +1 -0
- package/dist/cjs/queries/ObservableQueryConnectionFactory.js +62 -0
- package/dist/cjs/queries/ObservableQueryConnectionFactory.js.map +1 -0
- package/dist/cjs/queries/ObservableQueryConnectionPool.d.ts +9 -0
- package/dist/cjs/queries/ObservableQueryConnectionPool.d.ts.map +1 -0
- package/dist/cjs/queries/ObservableQueryConnectionPool.js +23 -0
- package/dist/cjs/queries/ObservableQueryConnectionPool.js.map +1 -0
- package/dist/cjs/queries/ObservableQueryFor.d.ts +1 -0
- package/dist/cjs/queries/ObservableQueryFor.d.ts.map +1 -1
- package/dist/cjs/queries/ObservableQueryFor.js +10 -5
- package/dist/cjs/queries/ObservableQueryFor.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryMultiplexer.d.ts +30 -0
- package/dist/cjs/queries/ObservableQueryMultiplexer.d.ts.map +1 -0
- package/dist/cjs/queries/ObservableQueryMultiplexer.js +120 -0
- package/dist/cjs/queries/ObservableQueryMultiplexer.js.map +1 -0
- package/dist/cjs/queries/QueryInstanceCache.d.ts +29 -0
- package/dist/cjs/queries/QueryInstanceCache.d.ts.map +1 -0
- package/dist/cjs/queries/QueryInstanceCache.js +95 -0
- package/dist/cjs/queries/QueryInstanceCache.js.map +1 -0
- package/dist/cjs/queries/QueryTransportMethod.d.ts +5 -0
- package/dist/cjs/queries/QueryTransportMethod.d.ts.map +1 -0
- package/dist/cjs/queries/QueryTransportMethod.js +8 -0
- package/dist/cjs/queries/QueryTransportMethod.js.map +1 -0
- package/dist/cjs/queries/ReconnectPolicy.d.ts +15 -0
- package/dist/cjs/queries/ReconnectPolicy.d.ts.map +1 -0
- package/dist/cjs/queries/ReconnectPolicy.js +43 -0
- package/dist/cjs/queries/ReconnectPolicy.js.map +1 -0
- package/dist/cjs/queries/ServerSentEventHubConnection.d.ts +39 -0
- package/dist/cjs/queries/ServerSentEventHubConnection.d.ts.map +1 -0
- package/dist/cjs/queries/ServerSentEventHubConnection.js +233 -0
- package/dist/cjs/queries/ServerSentEventHubConnection.js.map +1 -0
- package/dist/cjs/queries/ServerSentEventQueryConnection.d.ts +14 -0
- package/dist/cjs/queries/ServerSentEventQueryConnection.d.ts.map +1 -0
- package/dist/cjs/queries/ServerSentEventQueryConnection.js +59 -0
- package/dist/cjs/queries/ServerSentEventQueryConnection.js.map +1 -0
- package/dist/cjs/queries/WebSocketHubConnection.d.ts +55 -0
- package/dist/cjs/queries/WebSocketHubConnection.d.ts.map +1 -0
- package/dist/cjs/queries/WebSocketHubConnection.js +193 -0
- package/dist/cjs/queries/WebSocketHubConnection.js.map +1 -0
- package/dist/cjs/queries/for_HubConnectionKeepAlive/behavior.d.ts +2 -0
- package/dist/cjs/queries/for_HubConnectionKeepAlive/behavior.d.ts.map +1 -0
- package/dist/cjs/queries/for_ObservableQueryConnection/given/an_observable_query_connection.d.ts +1 -2
- package/dist/cjs/queries/for_ObservableQueryConnection/given/an_observable_query_connection.d.ts.map +1 -1
- package/dist/cjs/queries/for_ObservableQueryConnectionFactory/given/a_descriptor.d.ts +9 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionFactory/given/a_descriptor.d.ts.map +1 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_sse_transport.d.ts +2 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_sse_transport.d.ts.map +1 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_websocket_transport.d.ts +2 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_websocket_transport.d.ts.map +1 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_sse_transport.d.ts +2 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_sse_transport.d.ts.map +1 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_websocket_transport.d.ts +2 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_websocket_transport.d.ts.map +1 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_least_loaded_slot_is_chosen.d.ts +2 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_least_loaded_slot_is_chosen.d.ts.map +1 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_size_is_zero.d.ts +2 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_size_is_zero.d.ts.map +1 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionPool/when_acquiring/with_single_slot/and_one_subscriber.d.ts +2 -0
- package/dist/cjs/queries/for_ObservableQueryConnectionPool/when_acquiring/with_single_slot/and_one_subscriber.d.ts.map +1 -0
- package/dist/cjs/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_and_sse_transport.d.ts +2 -0
- package/dist/cjs/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_and_sse_transport.d.ts.map +1 -0
- package/dist/cjs/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_disabled_and_sse_transport.d.ts +2 -0
- package/dist/cjs/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_disabled_and_sse_transport.d.ts.map +1 -0
- package/dist/cjs/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_enabled.d.ts +2 -0
- package/dist/cjs/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_enabled.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_building_key/with_arguments.d.ts +2 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_building_key/with_arguments.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_building_key/with_empty_arguments_object.d.ts +2 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_building_key/with_empty_arguments_object.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_building_key/with_same_arguments_different_order.d.ts +2 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_building_key/with_same_arguments_different_order.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_building_key/without_arguments.d.ts +2 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_building_key/without_arguments.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_getting_last_result/with_no_result_stored.d.ts +2 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_getting_last_result/with_no_result_stored.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_getting_last_result/with_stored_result.d.ts +2 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_getting_last_result/with_stored_result.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_getting_or_creating/with_existing_entry.d.ts +2 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_getting_or_creating/with_existing_entry.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_getting_or_creating/with_new_entry.d.ts +2 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_getting_or_creating/with_new_entry.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_releasing/a_key_that_does_not_exist.d.ts +2 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_releasing/a_key_that_does_not_exist.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_releasing/one_of_two_subscribers.d.ts +2 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_releasing/one_of_two_subscribers.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_releasing/the_only_subscriber.d.ts +2 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_releasing/the_only_subscriber.d.ts.map +1 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_setting_last_result/with_a_result.d.ts +2 -0
- package/dist/cjs/queries/for_QueryInstanceCache/when_setting_last_result/with_a_result.d.ts.map +1 -0
- package/dist/cjs/queries/for_ReconnectPolicy/when_canceling/with_pending_timer.d.ts +2 -0
- package/dist/cjs/queries/for_ReconnectPolicy/when_canceling/with_pending_timer.d.ts.map +1 -0
- package/dist/cjs/queries/for_ReconnectPolicy/when_cancelling/with_pending_timer.d.ts +2 -0
- package/dist/cjs/queries/for_ReconnectPolicy/when_cancelling/with_pending_timer.d.ts.map +1 -0
- package/dist/cjs/queries/for_ReconnectPolicy/when_resetting/after_scheduling.d.ts +2 -0
- package/dist/cjs/queries/for_ReconnectPolicy/when_resetting/after_scheduling.d.ts.map +1 -0
- package/dist/cjs/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/delay_is_capped_at_max.d.ts +2 -0
- package/dist/cjs/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/delay_is_capped_at_max.d.ts.map +1 -0
- package/dist/cjs/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/first_attempt.d.ts +2 -0
- package/dist/cjs/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/first_attempt.d.ts.map +1 -0
- package/dist/cjs/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_reached/abandons_reconnect.d.ts +2 -0
- package/dist/cjs/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_reached/abandons_reconnect.d.ts.map +1 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.d.ts +21 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.d.ts.map +1 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_connect_timeout_fires/triggers_reconnect.d.ts +2 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_connect_timeout_fires/triggers_reconnect.d.ts.map +1 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.d.ts +2 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.d.ts.map +1 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_keep_alive_is_idle/triggers_reconnect.d.ts +2 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_keep_alive_is_idle/triggers_reconnect.d.ts.map +1 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.d.ts +2 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.d.ts.map +1 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_subscribing/queues_until_connected.d.ts +2 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_subscribing/queues_until_connected.d.ts.map +1 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_subscribing/sends_subscribe_post.d.ts +2 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_subscribing/sends_subscribe_post.d.ts.map +1 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_unsubscribing/the_only_query.d.ts +2 -0
- package/dist/cjs/queries/for_ServerSentEventHubConnection/when_unsubscribing/the_only_query.d.ts.map +1 -0
- package/dist/cjs/queries/for_ServerSentEventQueryConnection/when_connecting/with_query_arguments.d.ts +2 -0
- package/dist/cjs/queries/for_ServerSentEventQueryConnection/when_connecting/with_query_arguments.d.ts.map +1 -0
- package/dist/cjs/queries/for_ServerSentEventQueryConnection/when_connecting/without_event_source_available.d.ts +2 -0
- package/dist/cjs/queries/for_ServerSentEventQueryConnection/when_connecting/without_event_source_available.d.ts.map +1 -0
- package/dist/cjs/queries/for_ServerSentEventQueryConnection/when_disconnecting/after_connecting.d.ts +2 -0
- package/dist/cjs/queries/for_ServerSentEventQueryConnection/when_disconnecting/after_connecting.d.ts.map +1 -0
- package/dist/cjs/queries/for_ServerSentEventQueryConnection/when_disconnecting/before_message_arrives.d.ts +2 -0
- package/dist/cjs/queries/for_ServerSentEventQueryConnection/when_disconnecting/before_message_arrives.d.ts.map +1 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/given/a_web_socket_hub_connection.d.ts +23 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/given/a_web_socket_hub_connection.d.ts.map +1 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_disposing/cleans_up_resources.d.ts +2 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_disposing/cleans_up_resources.d.ts.map +1 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_keep_alive_is_idle/sends_a_ping.d.ts +2 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_keep_alive_is_idle/sends_a_ping.d.ts.map +1 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_receiving_a_message/resets_keep_alive_timer.d.ts +2 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_receiving_a_message/resets_keep_alive_timer.d.ts.map +1 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_reconnecting/after_unexpected_close.d.ts +2 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_reconnecting/after_unexpected_close.d.ts.map +1 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_reconnecting/resubscribes_all_queries.d.ts +2 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_reconnecting/resubscribes_all_queries.d.ts.map +1 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_subscribing/to_a_query.d.ts +2 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_subscribing/to_a_query.d.ts.map +1 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_unsubscribing/the_only_query.d.ts +2 -0
- package/dist/cjs/queries/for_WebSocketHubConnection/when_unsubscribing/the_only_query.d.ts.map +1 -0
- package/dist/cjs/queries/index.d.ts +12 -0
- package/dist/cjs/queries/index.d.ts.map +1 -1
- package/dist/cjs/queries/index.js +34 -0
- package/dist/cjs/queries/index.js.map +1 -1
- package/dist/esm/Globals.d.ts +4 -0
- package/dist/esm/Globals.d.ts.map +1 -1
- package/dist/esm/Globals.js +6 -1
- package/dist/esm/Globals.js.map +1 -1
- package/dist/esm/queries/HubConnectionKeepAlive.d.ts +11 -0
- package/dist/esm/queries/HubConnectionKeepAlive.d.ts.map +1 -0
- package/dist/esm/queries/HubConnectionKeepAlive.js +31 -0
- package/dist/esm/queries/HubConnectionKeepAlive.js.map +1 -0
- package/dist/esm/queries/IObservableQueryHubConnection.d.ts +11 -0
- package/dist/esm/queries/IObservableQueryHubConnection.d.ts.map +1 -0
- package/dist/esm/queries/IObservableQueryHubConnection.js +2 -0
- package/dist/esm/queries/IObservableQueryHubConnection.js.map +1 -0
- package/dist/esm/queries/IReconnectPolicy.d.ts +8 -0
- package/dist/esm/queries/IReconnectPolicy.d.ts.map +1 -0
- package/dist/esm/queries/IReconnectPolicy.js +2 -0
- package/dist/esm/queries/IReconnectPolicy.js.map +1 -0
- package/dist/esm/queries/ObservableQueryConnection.d.ts +3 -1
- package/dist/esm/queries/ObservableQueryConnection.d.ts.map +1 -1
- package/dist/esm/queries/ObservableQueryConnection.js +8 -21
- package/dist/esm/queries/ObservableQueryConnection.js.map +1 -1
- package/dist/esm/queries/ObservableQueryConnectionFactory.d.ts +13 -0
- package/dist/esm/queries/ObservableQueryConnectionFactory.d.ts.map +1 -0
- package/dist/esm/queries/ObservableQueryConnectionFactory.js +58 -0
- package/dist/esm/queries/ObservableQueryConnectionFactory.js.map +1 -0
- package/dist/esm/queries/ObservableQueryConnectionPool.d.ts +9 -0
- package/dist/esm/queries/ObservableQueryConnectionPool.d.ts.map +1 -0
- package/dist/esm/queries/ObservableQueryConnectionPool.js +21 -0
- package/dist/esm/queries/ObservableQueryConnectionPool.js.map +1 -0
- package/dist/esm/queries/ObservableQueryFor.d.ts +1 -0
- package/dist/esm/queries/ObservableQueryFor.d.ts.map +1 -1
- package/dist/esm/queries/ObservableQueryFor.js +10 -5
- package/dist/esm/queries/ObservableQueryFor.js.map +1 -1
- package/dist/esm/queries/ObservableQueryMultiplexer.d.ts +30 -0
- package/dist/esm/queries/ObservableQueryMultiplexer.d.ts.map +1 -0
- package/dist/esm/queries/ObservableQueryMultiplexer.js +114 -0
- package/dist/esm/queries/ObservableQueryMultiplexer.js.map +1 -0
- package/dist/esm/queries/QueryInstanceCache.d.ts +29 -0
- package/dist/esm/queries/QueryInstanceCache.d.ts.map +1 -0
- package/dist/esm/queries/QueryInstanceCache.js +93 -0
- package/dist/esm/queries/QueryInstanceCache.js.map +1 -0
- package/dist/esm/queries/QueryTransportMethod.d.ts +5 -0
- package/dist/esm/queries/QueryTransportMethod.d.ts.map +1 -0
- package/dist/esm/queries/QueryTransportMethod.js +8 -0
- package/dist/esm/queries/QueryTransportMethod.js.map +1 -0
- package/dist/esm/queries/ReconnectPolicy.d.ts +15 -0
- package/dist/esm/queries/ReconnectPolicy.d.ts.map +1 -0
- package/dist/esm/queries/ReconnectPolicy.js +41 -0
- package/dist/esm/queries/ReconnectPolicy.js.map +1 -0
- package/dist/esm/queries/ServerSentEventHubConnection.d.ts +39 -0
- package/dist/esm/queries/ServerSentEventHubConnection.d.ts.map +1 -0
- package/dist/esm/queries/ServerSentEventHubConnection.js +231 -0
- package/dist/esm/queries/ServerSentEventHubConnection.js.map +1 -0
- package/dist/esm/queries/ServerSentEventQueryConnection.d.ts +14 -0
- package/dist/esm/queries/ServerSentEventQueryConnection.d.ts.map +1 -0
- package/dist/esm/queries/ServerSentEventQueryConnection.js +56 -0
- package/dist/esm/queries/ServerSentEventQueryConnection.js.map +1 -0
- package/dist/esm/queries/WebSocketHubConnection.d.ts +55 -0
- package/dist/esm/queries/WebSocketHubConnection.d.ts.map +1 -0
- package/dist/esm/queries/WebSocketHubConnection.js +191 -0
- package/dist/esm/queries/WebSocketHubConnection.js.map +1 -0
- package/dist/esm/queries/for_HubConnectionKeepAlive/behavior.d.ts +2 -0
- package/dist/esm/queries/for_HubConnectionKeepAlive/behavior.d.ts.map +1 -0
- package/dist/esm/queries/for_HubConnectionKeepAlive/behavior.js +57 -0
- package/dist/esm/queries/for_HubConnectionKeepAlive/behavior.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnection/given/an_observable_query_connection.d.ts +1 -2
- package/dist/esm/queries/for_ObservableQueryConnection/given/an_observable_query_connection.d.ts.map +1 -1
- package/dist/esm/queries/for_ObservableQueryConnection/given/an_observable_query_connection.js +9 -5
- package/dist/esm/queries/for_ObservableQueryConnection/given/an_observable_query_connection.js.map +1 -1
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/given/a_descriptor.d.ts +9 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/given/a_descriptor.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/given/a_descriptor.js +19 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/given/a_descriptor.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_sse_transport.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_sse_transport.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_sse_transport.js +49 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_sse_transport.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_websocket_transport.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_websocket_transport.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_websocket_transport.js +47 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_websocket_transport.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_sse_transport.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_sse_transport.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_sse_transport.js +54 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_sse_transport.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_websocket_transport.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_websocket_transport.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_websocket_transport.js +49 -0
- package/dist/esm/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_websocket_transport.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_least_loaded_slot_is_chosen.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_least_loaded_slot_is_chosen.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_least_loaded_slot_is_chosen.js +34 -0
- package/dist/esm/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_least_loaded_slot_is_chosen.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_size_is_zero.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_size_is_zero.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_size_is_zero.js +18 -0
- package/dist/esm/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_size_is_zero.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionPool/when_acquiring/with_single_slot/and_one_subscriber.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryConnectionPool/when_acquiring/with_single_slot/and_one_subscriber.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryConnectionPool/when_acquiring/with_single_slot/and_one_subscriber.js +32 -0
- package/dist/esm/queries/for_ObservableQueryConnectionPool/when_acquiring/with_single_slot/and_one_subscriber.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_and_sse_transport.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_and_sse_transport.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_and_sse_transport.js +54 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_and_sse_transport.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_disabled_and_sse_transport.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_disabled_and_sse_transport.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_disabled_and_sse_transport.js +55 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_disabled_and_sse_transport.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_enabled.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_enabled.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_enabled.js +45 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_enabled.js.map +1 -0
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_partially_missing_required_arguments.js +18 -11
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_partially_missing_required_arguments.js.map +1 -1
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_route_and_query_args.js +12 -5
- package/dist/esm/queries/for_ObservableQueryFor/when_subscribing/with_route_and_query_args.js.map +1 -1
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/with_arguments.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/with_arguments.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/with_arguments.js +12 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/with_arguments.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/with_empty_arguments_object.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/with_empty_arguments_object.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/with_empty_arguments_object.js +11 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/with_empty_arguments_object.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/with_same_arguments_different_order.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/with_same_arguments_different_order.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/with_same_arguments_different_order.js +13 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/with_same_arguments_different_order.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/without_arguments.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/without_arguments.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/without_arguments.js +11 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_building_key/without_arguments.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_last_result/with_no_result_stored.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_last_result/with_no_result_stored.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_last_result/with_no_result_stored.js +12 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_last_result/with_no_result_stored.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_last_result/with_stored_result.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_last_result/with_stored_result.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_last_result/with_stored_result.js +16 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_last_result/with_stored_result.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_or_creating/with_existing_entry.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_or_creating/with_existing_entry.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_or_creating/with_existing_entry.js +23 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_or_creating/with_existing_entry.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_or_creating/with_new_entry.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_or_creating/with_new_entry.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_or_creating/with_new_entry.js +16 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_getting_or_creating/with_new_entry.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_releasing/a_key_that_does_not_exist.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_releasing/a_key_that_does_not_exist.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_releasing/a_key_that_does_not_exist.js +17 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_releasing/a_key_that_does_not_exist.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_releasing/one_of_two_subscribers.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_releasing/one_of_two_subscribers.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_releasing/one_of_two_subscribers.js +13 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_releasing/one_of_two_subscribers.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_releasing/the_only_subscriber.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_releasing/the_only_subscriber.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_releasing/the_only_subscriber.js +17 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_releasing/the_only_subscriber.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_a_result.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_a_result.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_a_result.js +15 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_a_result.js.map +1 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_canceling/with_pending_timer.d.ts +2 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_canceling/with_pending_timer.d.ts.map +1 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_canceling/with_pending_timer.js +24 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_canceling/with_pending_timer.js.map +1 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_cancelling/with_pending_timer.d.ts +2 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_cancelling/with_pending_timer.d.ts.map +1 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_cancelling/with_pending_timer.js +24 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_cancelling/with_pending_timer.js.map +1 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_resetting/after_scheduling.d.ts +2 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_resetting/after_scheduling.d.ts.map +1 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_resetting/after_scheduling.js +29 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_resetting/after_scheduling.js.map +1 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/delay_is_capped_at_max.d.ts +2 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/delay_is_capped_at_max.d.ts.map +1 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/delay_is_capped_at_max.js +33 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/delay_is_capped_at_max.js.map +1 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/first_attempt.d.ts +2 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/first_attempt.d.ts.map +1 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/first_attempt.js +28 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/first_attempt.js.map +1 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_reached/abandons_reconnect.d.ts +2 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_reached/abandons_reconnect.d.ts.map +1 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_reached/abandons_reconnect.js +29 -0
- package/dist/esm/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_reached/abandons_reconnect.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.d.ts +21 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.js +50 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connect_timeout_fires/triggers_reconnect.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connect_timeout_fires/triggers_reconnect.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connect_timeout_fires/triggers_reconnect.js +24 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_connect_timeout_fires/triggers_reconnect.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.js +27 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_keep_alive_is_idle/triggers_reconnect.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_keep_alive_is_idle/triggers_reconnect.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_keep_alive_is_idle/triggers_reconnect.js +26 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_keep_alive_is_idle/triggers_reconnect.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.js +46 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscribing/queues_until_connected.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscribing/queues_until_connected.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscribing/queues_until_connected.js +21 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscribing/queues_until_connected.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscribing/sends_subscribe_post.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscribing/sends_subscribe_post.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscribing/sends_subscribe_post.js +32 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_subscribing/sends_subscribe_post.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_unsubscribing/the_only_query.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_unsubscribing/the_only_query.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_unsubscribing/the_only_query.js +21 -0
- package/dist/esm/queries/for_ServerSentEventHubConnection/when_unsubscribing/the_only_query.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_connecting/with_query_arguments.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_connecting/with_query_arguments.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_connecting/with_query_arguments.js +38 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_connecting/with_query_arguments.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_connecting/without_event_source_available.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_connecting/without_event_source_available.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_connecting/without_event_source_available.js +23 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_connecting/without_event_source_available.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_disconnecting/after_connecting.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_disconnecting/after_connecting.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_disconnecting/after_connecting.js +24 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_disconnecting/after_connecting.js.map +1 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_disconnecting/before_message_arrives.d.ts +2 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_disconnecting/before_message_arrives.d.ts.map +1 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_disconnecting/before_message_arrives.js +24 -0
- package/dist/esm/queries/for_ServerSentEventQueryConnection/when_disconnecting/before_message_arrives.js.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/given/a_web_socket_hub_connection.d.ts +23 -0
- package/dist/esm/queries/for_WebSocketHubConnection/given/a_web_socket_hub_connection.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/given/a_web_socket_hub_connection.js +47 -0
- package/dist/esm/queries/for_WebSocketHubConnection/given/a_web_socket_hub_connection.js.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_disposing/cleans_up_resources.d.ts +2 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_disposing/cleans_up_resources.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_disposing/cleans_up_resources.js +24 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_disposing/cleans_up_resources.js.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_keep_alive_is_idle/sends_a_ping.d.ts +2 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_keep_alive_is_idle/sends_a_ping.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_keep_alive_is_idle/sends_a_ping.js +29 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_keep_alive_is_idle/sends_a_ping.js.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_receiving_a_message/resets_keep_alive_timer.d.ts +2 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_receiving_a_message/resets_keep_alive_timer.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_receiving_a_message/resets_keep_alive_timer.js +31 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_receiving_a_message/resets_keep_alive_timer.js.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/after_unexpected_close.d.ts +2 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/after_unexpected_close.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/after_unexpected_close.js +30 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/after_unexpected_close.js.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/resubscribes_all_queries.d.ts +2 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/resubscribes_all_queries.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/resubscribes_all_queries.js +31 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_reconnecting/resubscribes_all_queries.js.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_subscribing/to_a_query.d.ts +2 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_subscribing/to_a_query.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_subscribing/to_a_query.js +32 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_subscribing/to_a_query.js.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_unsubscribing/the_only_query.d.ts +2 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_unsubscribing/the_only_query.d.ts.map +1 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_unsubscribing/the_only_query.js +23 -0
- package/dist/esm/queries/for_WebSocketHubConnection/when_unsubscribing/the_only_query.js.map +1 -0
- package/dist/esm/queries/index.d.ts +12 -0
- package/dist/esm/queries/index.d.ts.map +1 -1
- package/dist/esm/queries/index.js +10 -0
- package/dist/esm/queries/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/queries/HubConnectionKeepAlive.ts +61 -0
- package/queries/IObservableQueryHubConnection.ts +50 -0
- package/queries/IReconnectPolicy.ts +39 -0
- package/queries/ObservableQueryConnection.ts +8 -24
- package/queries/ObservableQueryConnectionFactory.ts +118 -0
- package/queries/ObservableQueryConnectionPool.ts +64 -0
- package/queries/ObservableQueryFor.ts +11 -5
- package/queries/ObservableQueryMultiplexer.ts +214 -0
- package/queries/QueryInstanceCache.ts +243 -0
- package/queries/QueryTransportMethod.ts +17 -0
- package/queries/ReconnectPolicy.ts +68 -0
- package/queries/ServerSentEventHubConnection.ts +309 -0
- package/queries/ServerSentEventQueryConnection.ts +84 -0
- package/queries/WebSocketHubConnection.ts +291 -0
- package/queries/for_HubConnectionKeepAlive/behavior.ts +73 -0
- package/queries/for_ObservableQueryConnection/given/an_observable_query_connection.ts +13 -9
- package/queries/for_ObservableQueryConnectionFactory/given/a_descriptor.ts +26 -0
- package/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_sse_transport.ts +62 -0
- package/queries/for_ObservableQueryConnectionFactory/when_creating/with_direct_mode_and_websocket_transport.ts +59 -0
- package/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_sse_transport.ts +69 -0
- package/queries/for_ObservableQueryConnectionFactory/when_creating/with_hub_mode_and_websocket_transport.ts +61 -0
- package/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_least_loaded_slot_is_chosen.ts +47 -0
- package/queries/for_ObservableQueryConnectionPool/when_acquiring/with_multiple_slots/and_size_is_zero.ts +26 -0
- package/queries/for_ObservableQueryConnectionPool/when_acquiring/with_single_slot/and_one_subscriber.ts +44 -0
- package/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_and_sse_transport.ts +69 -0
- package/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_disabled_and_sse_transport.ts +70 -0
- package/queries/for_ObservableQueryFor/when_subscribing/with_direct_mode_enabled.ts +57 -0
- package/queries/for_ObservableQueryFor/when_subscribing/with_partially_missing_required_arguments.ts +19 -11
- package/queries/for_ObservableQueryFor/when_subscribing/with_route_and_query_args.ts +14 -7
- package/queries/for_QueryInstanceCache/when_building_key/with_arguments.ts +17 -0
- package/queries/for_QueryInstanceCache/when_building_key/with_empty_arguments_object.ts +16 -0
- package/queries/for_QueryInstanceCache/when_building_key/with_same_arguments_different_order.ts +18 -0
- package/queries/for_QueryInstanceCache/when_building_key/without_arguments.ts +16 -0
- package/queries/for_QueryInstanceCache/when_getting_last_result/with_no_result_stored.ts +17 -0
- package/queries/for_QueryInstanceCache/when_getting_last_result/with_stored_result.ts +23 -0
- package/queries/for_QueryInstanceCache/when_getting_or_creating/with_existing_entry.ts +29 -0
- package/queries/for_QueryInstanceCache/when_getting_or_creating/with_new_entry.ts +21 -0
- package/queries/for_QueryInstanceCache/when_releasing/a_key_that_does_not_exist.ts +21 -0
- package/queries/for_QueryInstanceCache/when_releasing/one_of_two_subscribers.ts +18 -0
- package/queries/for_QueryInstanceCache/when_releasing/the_only_subscriber.ts +23 -0
- package/queries/for_QueryInstanceCache/when_setting_last_result/with_a_result.ts +20 -0
- package/queries/for_ReconnectPolicy/when_canceling/with_pending_timer.ts +33 -0
- package/queries/for_ReconnectPolicy/when_cancelling/with_pending_timer.ts +33 -0
- package/queries/for_ReconnectPolicy/when_resetting/after_scheduling.ts +39 -0
- package/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/delay_is_capped_at_max.ts +44 -0
- package/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_not_reached/first_attempt.ts +38 -0
- package/queries/for_ReconnectPolicy/when_scheduling/and_max_attempts_reached/abandons_reconnect.ts +39 -0
- package/queries/for_ServerSentEventHubConnection/given/a_server_sent_event_hub_connection.ts +85 -0
- package/queries/for_ServerSentEventHubConnection/when_connect_timeout_fires/triggers_reconnect.ts +46 -0
- package/queries/for_ServerSentEventHubConnection/when_disposing/cleans_up_resources.ts +34 -0
- package/queries/for_ServerSentEventHubConnection/when_keep_alive_is_idle/triggers_reconnect.ts +48 -0
- package/queries/for_ServerSentEventHubConnection/when_reconnecting/after_error.ts +62 -0
- package/queries/for_ServerSentEventHubConnection/when_subscribing/queues_until_connected.ts +31 -0
- package/queries/for_ServerSentEventHubConnection/when_subscribing/sends_subscribe_post.ts +42 -0
- package/queries/for_ServerSentEventHubConnection/when_unsubscribing/the_only_query.ts +32 -0
- package/queries/for_ServerSentEventQueryConnection/when_connecting/with_query_arguments.ts +63 -0
- package/queries/for_ServerSentEventQueryConnection/when_connecting/without_event_source_available.ts +31 -0
- package/queries/for_ServerSentEventQueryConnection/when_disconnecting/after_connecting.ts +36 -0
- package/queries/for_ServerSentEventQueryConnection/when_disconnecting/before_message_arrives.ts +38 -0
- package/queries/for_WebSocketHubConnection/given/a_web_socket_hub_connection.ts +81 -0
- package/queries/for_WebSocketHubConnection/when_disposing/cleans_up_resources.ts +31 -0
- package/queries/for_WebSocketHubConnection/when_keep_alive_is_idle/sends_a_ping.ts +47 -0
- package/queries/for_WebSocketHubConnection/when_receiving_a_message/resets_keep_alive_timer.ts +53 -0
- package/queries/for_WebSocketHubConnection/when_reconnecting/after_unexpected_close.ts +41 -0
- package/queries/for_WebSocketHubConnection/when_reconnecting/resubscribes_all_queries.ts +43 -0
- package/queries/for_WebSocketHubConnection/when_subscribing/to_a_query.ts +42 -0
- package/queries/for_WebSocketHubConnection/when_unsubscribing/the_only_query.ts +30 -0
- package/queries/index.ts +12 -0
package/Globals.ts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
// Copyright (c) Cratis. All rights reserved.
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
3
|
|
|
4
|
+
import { QueryTransportMethod } from './queries/QueryTransportMethod';
|
|
5
|
+
|
|
4
6
|
export interface IGlobals {
|
|
5
7
|
microservice: string;
|
|
6
8
|
apiBasePath: string;
|
|
7
9
|
origin: string;
|
|
8
10
|
microserviceHttpHeader: string;
|
|
9
11
|
microserviceWSQueryArgument: string;
|
|
12
|
+
queryTransportMethod: QueryTransportMethod;
|
|
13
|
+
/**
|
|
14
|
+
* Number of hub connections maintained for observable queries.
|
|
15
|
+
* When greater than one, queries are distributed across the pool round-robin.
|
|
16
|
+
* Only applies when {@link queryTransportMethod} is a centralized hub transport.
|
|
17
|
+
* Defaults to 1.
|
|
18
|
+
*/
|
|
19
|
+
queryConnectionCount: number;
|
|
20
|
+
/**
|
|
21
|
+
* When true, observable queries connect directly to the per-query WebSocket URL
|
|
22
|
+
* instead of routing through the centralized hub endpoint.
|
|
23
|
+
* Defaults to false (use the centralized hub).
|
|
24
|
+
*/
|
|
25
|
+
queryDirectMode: boolean;
|
|
10
26
|
}
|
|
11
27
|
|
|
12
28
|
export const Globals: IGlobals = {
|
|
@@ -14,5 +30,8 @@ export const Globals: IGlobals = {
|
|
|
14
30
|
apiBasePath: '',
|
|
15
31
|
origin: '',
|
|
16
32
|
microserviceHttpHeader: 'x-cratis-microservice',
|
|
17
|
-
microserviceWSQueryArgument: 'x-cratis-microservice'
|
|
33
|
+
microserviceWSQueryArgument: 'x-cratis-microservice',
|
|
34
|
+
queryTransportMethod: QueryTransportMethod.WebSocket,
|
|
35
|
+
queryConnectionCount: 1,
|
|
36
|
+
queryDirectMode: false,
|
|
18
37
|
};
|
package/dist/cjs/Globals.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { QueryTransportMethod } from './queries/QueryTransportMethod';
|
|
1
2
|
export interface IGlobals {
|
|
2
3
|
microservice: string;
|
|
3
4
|
apiBasePath: string;
|
|
4
5
|
origin: string;
|
|
5
6
|
microserviceHttpHeader: string;
|
|
6
7
|
microserviceWSQueryArgument: string;
|
|
8
|
+
queryTransportMethod: QueryTransportMethod;
|
|
9
|
+
queryConnectionCount: number;
|
|
10
|
+
queryDirectMode: boolean;
|
|
7
11
|
}
|
|
8
12
|
export declare const Globals: IGlobals;
|
|
9
13
|
//# sourceMappingURL=Globals.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Globals.d.ts","sourceRoot":"","sources":["../../Globals.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,QAAQ;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2BAA2B,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Globals.d.ts","sourceRoot":"","sources":["../../Globals.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAEtE,MAAM,WAAW,QAAQ;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2BAA2B,EAAE,MAAM,CAAC;IACpC,oBAAoB,EAAE,oBAAoB,CAAC;IAO3C,oBAAoB,EAAE,MAAM,CAAC;IAM7B,eAAe,EAAE,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,OAAO,EAAE,QASrB,CAAC"}
|
package/dist/cjs/Globals.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var QueryTransportMethod = require('./queries/QueryTransportMethod.js');
|
|
4
|
+
|
|
3
5
|
const Globals = {
|
|
4
6
|
microservice: '',
|
|
5
7
|
apiBasePath: '',
|
|
6
8
|
origin: '',
|
|
7
9
|
microserviceHttpHeader: 'x-cratis-microservice',
|
|
8
|
-
microserviceWSQueryArgument: 'x-cratis-microservice'
|
|
10
|
+
microserviceWSQueryArgument: 'x-cratis-microservice',
|
|
11
|
+
queryTransportMethod: QueryTransportMethod.QueryTransportMethod.WebSocket,
|
|
12
|
+
queryConnectionCount: 1,
|
|
13
|
+
queryDirectMode: false,
|
|
9
14
|
};
|
|
10
15
|
|
|
11
16
|
exports.Globals = Globals;
|
package/dist/cjs/Globals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Globals.js","sources":["../../Globals.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport interface IGlobals {\n microservice: string;\n apiBasePath: string;\n origin: string;\n microserviceHttpHeader: string;\n microserviceWSQueryArgument: string;\n}\n\nexport const Globals: IGlobals = {\n microservice: '',\n apiBasePath: '',\n origin: '',\n microserviceHttpHeader: 'x-cratis-microservice',\n microserviceWSQueryArgument: 'x-cratis-microservice'
|
|
1
|
+
{"version":3,"file":"Globals.js","sources":["../../Globals.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { QueryTransportMethod } from './queries/QueryTransportMethod';\n\nexport interface IGlobals {\n microservice: string;\n apiBasePath: string;\n origin: string;\n microserviceHttpHeader: string;\n microserviceWSQueryArgument: string;\n queryTransportMethod: QueryTransportMethod;\n /**\n * Number of hub connections maintained for observable queries.\n * When greater than one, queries are distributed across the pool round-robin.\n * Only applies when {@link queryTransportMethod} is a centralized hub transport.\n * Defaults to 1.\n */\n queryConnectionCount: number;\n /**\n * When true, observable queries connect directly to the per-query WebSocket URL\n * instead of routing through the centralized hub endpoint.\n * Defaults to false (use the centralized hub).\n */\n queryDirectMode: boolean;\n}\n\nexport const Globals: IGlobals = {\n microservice: '',\n apiBasePath: '',\n origin: '',\n microserviceHttpHeader: 'x-cratis-microservice',\n microserviceWSQueryArgument: 'x-cratis-microservice',\n queryTransportMethod: QueryTransportMethod.WebSocket,\n queryConnectionCount: 1,\n queryDirectMode: false,\n};"],"names":["QueryTransportMethod"],"mappings":";;;;AA2BO,MAAM,OAAO,GAAa;AAC7B,IAAA,YAAY,EAAE,EAAE;AAChB,IAAA,WAAW,EAAE,EAAE;AACf,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,sBAAsB,EAAE,uBAAuB;AAC/C,IAAA,2BAA2B,EAAE,uBAAuB;IACpD,oBAAoB,EAAEA,yCAAoB,CAAC,SAAS;AACpD,IAAA,oBAAoB,EAAE,CAAC;AACvB,IAAA,eAAe,EAAE,KAAK;;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class HubConnectionKeepAlive {
|
|
2
|
+
private readonly _intervalMs;
|
|
3
|
+
private readonly _onIdle;
|
|
4
|
+
private _lastActivityTime;
|
|
5
|
+
private _timer?;
|
|
6
|
+
constructor(_intervalMs: number, _onIdle: () => void);
|
|
7
|
+
start(): void;
|
|
8
|
+
stop(): void;
|
|
9
|
+
recordActivity(): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=HubConnectionKeepAlive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HubConnectionKeepAlive.d.ts","sourceRoot":"","sources":["../../../queries/HubConnectionKeepAlive.ts"],"names":[],"mappings":"AAeA,qBAAa,sBAAsB;IAW3B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAX5B,OAAO,CAAC,iBAAiB,CAAc;IACvC,OAAO,CAAC,MAAM,CAAC,CAAiC;gBAS3B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,IAAI;IAMxC,KAAK,IAAI,IAAI;IAab,IAAI,IAAI,IAAI;IAWZ,cAAc,IAAI,IAAI;CAGzB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
class HubConnectionKeepAlive {
|
|
4
|
+
_intervalMs;
|
|
5
|
+
_onIdle;
|
|
6
|
+
_lastActivityTime = Date.now();
|
|
7
|
+
_timer;
|
|
8
|
+
constructor(_intervalMs, _onIdle) {
|
|
9
|
+
this._intervalMs = _intervalMs;
|
|
10
|
+
this._onIdle = _onIdle;
|
|
11
|
+
}
|
|
12
|
+
start() {
|
|
13
|
+
this.stop();
|
|
14
|
+
this._lastActivityTime = Date.now();
|
|
15
|
+
this._timer = setInterval(() => {
|
|
16
|
+
if (Date.now() - this._lastActivityTime >= this._intervalMs) {
|
|
17
|
+
this._onIdle();
|
|
18
|
+
}
|
|
19
|
+
}, this._intervalMs);
|
|
20
|
+
}
|
|
21
|
+
stop() {
|
|
22
|
+
if (this._timer !== undefined) {
|
|
23
|
+
clearInterval(this._timer);
|
|
24
|
+
this._timer = undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
recordActivity() {
|
|
28
|
+
this._lastActivityTime = Date.now();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.HubConnectionKeepAlive = HubConnectionKeepAlive;
|
|
33
|
+
//# sourceMappingURL=HubConnectionKeepAlive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HubConnectionKeepAlive.js","sources":["../../../queries/HubConnectionKeepAlive.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Manages keep-alive behavior for hub connections (both WebSocket and Server-Sent Events).\n *\n * Records connection activity (any message received or sent). An interval fires every\n * {@link intervalMs} milliseconds; if no activity has been recorded since the last tick the\n * provided {@link onIdle} callback is invoked — the caller decides whether to send a ping,\n * trigger a reconnect, or take some other action.\n *\n * Both {@link WebSocketHubConnection} and {@link ServerSentEventHubConnection} own one instance\n * of this class so the keep-alive logic is written once and behaves identically for both\n * transports.\n */\nexport class HubConnectionKeepAlive {\n private _lastActivityTime = Date.now();\n private _timer?: ReturnType<typeof setInterval>;\n\n /**\n * Initializes a new instance of {@link HubConnectionKeepAlive}.\n * @param {number} intervalMs How often (in milliseconds) to check for idle connections.\n * @param {() => void} onIdle Callback invoked when the interval fires and no activity has\n * been recorded in the last {@link intervalMs} milliseconds.\n */\n constructor(\n private readonly _intervalMs: number,\n private readonly _onIdle: () => void,\n ) {}\n\n /**\n * Start the keep-alive timer. Safe to call multiple times — a running timer is stopped first.\n */\n start(): void {\n this.stop();\n this._lastActivityTime = Date.now();\n this._timer = setInterval(() => {\n if (Date.now() - this._lastActivityTime >= this._intervalMs) {\n this._onIdle();\n }\n }, this._intervalMs);\n }\n\n /**\n * Stop the keep-alive timer.\n */\n stop(): void {\n if (this._timer !== undefined) {\n clearInterval(this._timer);\n this._timer = undefined;\n }\n }\n\n /**\n * Record that the connection has been active (message sent or received).\n * Resets the idle timer so that a keep-alive is not sent while data is already flowing.\n */\n recordActivity(): void {\n this._lastActivityTime = Date.now();\n }\n}\n"],"names":[],"mappings":";;MAea,sBAAsB,CAAA;AAWV,IAAA,WAAA;AACA,IAAA,OAAA;AAXb,IAAA,iBAAiB,GAAG,IAAI,CAAC,GAAG,EAAE;AAC9B,IAAA,MAAM;IAQd,WAAA,CACqB,WAAmB,EACnB,OAAmB,EAAA;QADnB,IAAA,CAAA,WAAW,GAAX,WAAW;QACX,IAAA,CAAA,OAAO,GAAP,OAAO;IACzB;IAKH,KAAK,GAAA;QACD,IAAI,CAAC,IAAI,EAAE;AACX,QAAA,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,GAAG,EAAE;AACnC,QAAA,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,MAAK;AAC3B,YAAA,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,WAAW,EAAE;gBACzD,IAAI,CAAC,OAAO,EAAE;YAClB;AACJ,QAAA,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC;IACxB;IAKA,IAAI,GAAA;AACA,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;AAC3B,YAAA,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;AAC1B,YAAA,IAAI,CAAC,MAAM,GAAG,SAAS;QAC3B;IACJ;IAMA,cAAc,GAAA;AACV,QAAA,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,GAAG,EAAE;IACvC;AACH;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DataReceived } from './ObservableQueryConnection';
|
|
2
|
+
import { SubscriptionRequest } from './WebSocketHubConnection';
|
|
3
|
+
export interface IObservableQueryHubConnection {
|
|
4
|
+
readonly queryCount: number;
|
|
5
|
+
readonly lastPingLatency: number;
|
|
6
|
+
readonly averageLatency: number;
|
|
7
|
+
subscribe(queryId: string, request: SubscriptionRequest, callback: DataReceived<any>): void;
|
|
8
|
+
unsubscribe(queryId: string): void;
|
|
9
|
+
dispose(): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=IObservableQueryHubConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IObservableQueryHubConnection.d.ts","sourceRoot":"","sources":["../../../queries/IObservableQueryHubConnection.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAW/D,MAAM,WAAW,6BAA6B;IAI1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAK5B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAKjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAQhC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAM5F,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAKnC,OAAO,IAAI,IAAI,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IReconnectPolicy.d.ts","sourceRoot":"","sources":["../../../queries/IReconnectPolicy.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC;AAM3C,MAAM,WAAW,gBAAgB;IAI7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IASzB,QAAQ,CAAC,WAAW,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAMjE,KAAK,IAAI,IAAI,CAAC;IAMd,MAAM,IAAI,IAAI,CAAC;CAClB"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { IObservableQueryConnection } from './IObservableQueryConnection';
|
|
2
|
+
import { IReconnectPolicy } from './IReconnectPolicy';
|
|
2
3
|
import { QueryResult } from './QueryResult';
|
|
3
4
|
export type DataReceived<TDataType> = (data: QueryResult<TDataType>) => void;
|
|
4
5
|
export declare class ObservableQueryConnection<TDataType> implements IObservableQueryConnection<TDataType> {
|
|
5
6
|
private readonly _microservice;
|
|
7
|
+
private readonly _reconnectPolicy;
|
|
6
8
|
private _socket;
|
|
7
9
|
private _disconnected;
|
|
8
10
|
private _url;
|
|
@@ -12,7 +14,7 @@ export declare class ObservableQueryConnection<TDataType> implements IObservable
|
|
|
12
14
|
private _lastPongLatency;
|
|
13
15
|
private _latencySamples;
|
|
14
16
|
private _connectionStartTime?;
|
|
15
|
-
constructor(url: URL, _microservice: string, pingIntervalMs?: number);
|
|
17
|
+
constructor(url: URL, _microservice: string, pingIntervalMs?: number, _reconnectPolicy?: IReconnectPolicy);
|
|
16
18
|
dispose(): void;
|
|
17
19
|
get lastPingLatency(): number;
|
|
18
20
|
get averageLatency(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableQueryConnection.d.ts","sourceRoot":"","sources":["../../../queries/ObservableQueryConnection.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,MAAM,MAAM,YAAY,CAAC,SAAS,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;AAK7E,qBAAa,yBAAyB,CAAC,SAAS,CAAE,YAAW,0BAA0B,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ObservableQueryConnection.d.ts","sourceRoot":"","sources":["../../../queries/ObservableQueryConnection.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,MAAM,MAAM,YAAY,CAAC,SAAS,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;AAK7E,qBAAa,yBAAyB,CAAC,SAAS,CAAE,YAAW,0BAA0B,CAAC,SAAS,CAAC;IAmBxE,OAAO,CAAC,QAAQ,CAAC,aAAa;IAA0C,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAjB/H,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,aAAa,CAAC,CAAiC;IACvD,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,iBAAiB,CAAC,CAAS;IACnC,OAAO,CAAC,gBAAgB,CAAa;IACrC,OAAO,CAAC,eAAe,CAAgB;IACvC,OAAO,CAAC,oBAAoB,CAAC,CAAS;gBAS1B,GAAG,EAAE,GAAG,EAAmB,aAAa,EAAE,MAAM,EAAE,cAAc,GAAE,MAAc,EAAmB,gBAAgB,GAAE,gBAAwC;IAkBzK,OAAO;IAOP,IAAI,eAAe,IAAI,MAAM,CAE5B;IAKD,IAAI,cAAc,IAAI,MAAM,CAM3B;IAGD,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM;IA+CtE,UAAU;IAaV,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,QAAQ;IAchB,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,UAAU;CAYrB"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Globals = require('../Globals.js');
|
|
4
|
+
var ReconnectPolicy = require('./ReconnectPolicy.js');
|
|
4
5
|
var WebSocketMessage = require('./WebSocketMessage.js');
|
|
5
6
|
|
|
6
7
|
class ObservableQueryConnection {
|
|
7
8
|
_microservice;
|
|
9
|
+
_reconnectPolicy;
|
|
8
10
|
_socket;
|
|
9
11
|
_disconnected = false;
|
|
10
12
|
_url;
|
|
@@ -14,8 +16,9 @@ class ObservableQueryConnection {
|
|
|
14
16
|
_lastPongLatency = 0;
|
|
15
17
|
_latencySamples = [];
|
|
16
18
|
_connectionStartTime;
|
|
17
|
-
constructor(url, _microservice, pingIntervalMs = 10000) {
|
|
19
|
+
constructor(url, _microservice, pingIntervalMs = 10000, _reconnectPolicy = new ReconnectPolicy.ReconnectPolicy()) {
|
|
18
20
|
this._microservice = _microservice;
|
|
21
|
+
this._reconnectPolicy = _reconnectPolicy;
|
|
19
22
|
this._pingIntervalMs = pingIntervalMs;
|
|
20
23
|
const secure = url.protocol?.indexOf('https') === 0 || false;
|
|
21
24
|
this._url = `${secure ? 'wss' : 'ws'}://${url.host}${url.pathname}${url.search}`;
|
|
@@ -54,30 +57,13 @@ class ObservableQueryConnection {
|
|
|
54
57
|
const query = Object.keys(queryArguments).map(key => `${key}=${queryArguments[key]}`).join('&');
|
|
55
58
|
url = `${url}${query}`;
|
|
56
59
|
}
|
|
57
|
-
let timeToWait = 500;
|
|
58
|
-
const timeExponent = 500;
|
|
59
|
-
const retries = 100;
|
|
60
|
-
let currentAttempt = 0;
|
|
61
|
-
const maxTime = 10_000;
|
|
62
60
|
const connectSocket = () => {
|
|
63
|
-
const retry = () => {
|
|
64
|
-
currentAttempt++;
|
|
65
|
-
if (currentAttempt > retries) {
|
|
66
|
-
console.log(`Attempted ${retries} retries for route '${url}'. Abandoning.`);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
console.log(`Attempting to reconnect for '${url}' (#${currentAttempt})`);
|
|
70
|
-
setTimeout(connectSocket, timeToWait);
|
|
71
|
-
timeToWait += (timeExponent * currentAttempt);
|
|
72
|
-
timeToWait = timeToWait > maxTime ? maxTime : timeToWait;
|
|
73
|
-
};
|
|
74
61
|
this._socket = new WebSocket(url);
|
|
75
62
|
this._socket.onopen = () => {
|
|
76
63
|
if (this._disconnected)
|
|
77
64
|
return;
|
|
78
65
|
console.log(`Connection for '${url}' established`);
|
|
79
|
-
|
|
80
|
-
currentAttempt = 0;
|
|
66
|
+
this._reconnectPolicy.reset();
|
|
81
67
|
this._connectionStartTime = Date.now();
|
|
82
68
|
this.startPinging();
|
|
83
69
|
};
|
|
@@ -86,14 +72,14 @@ class ObservableQueryConnection {
|
|
|
86
72
|
return;
|
|
87
73
|
console.log(`Unexpected connection closed for route '${url}'`);
|
|
88
74
|
this.stopPinging();
|
|
89
|
-
|
|
75
|
+
this._reconnectPolicy.schedule(connectSocket, url);
|
|
90
76
|
};
|
|
91
77
|
this._socket.onerror = (error) => {
|
|
92
78
|
if (this._disconnected)
|
|
93
79
|
return;
|
|
94
80
|
console.log(`Error with connection for '${url}' - ${error}`);
|
|
95
81
|
this.stopPinging();
|
|
96
|
-
|
|
82
|
+
this._reconnectPolicy.schedule(connectSocket, url);
|
|
97
83
|
};
|
|
98
84
|
this._socket.onmessage = (ev) => {
|
|
99
85
|
if (this._disconnected) {
|
|
@@ -113,6 +99,7 @@ class ObservableQueryConnection {
|
|
|
113
99
|
}
|
|
114
100
|
console.log(`Disconnecting '${this._url}'`);
|
|
115
101
|
this._disconnected = true;
|
|
102
|
+
this._reconnectPolicy.cancel();
|
|
116
103
|
this.stopPinging();
|
|
117
104
|
this._socket?.close();
|
|
118
105
|
console.log(`Connection for '${this._url}' closed`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableQueryConnection.js","sources":["../../../queries/ObservableQueryConnection.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Globals } from '../Globals';\nimport { IObservableQueryConnection } from './IObservableQueryConnection';\nimport { QueryResult } from './QueryResult';\nimport { WebSocketMessage, WebSocketMessageType } from './WebSocketMessage';\n\nexport type DataReceived<TDataType> = (data: QueryResult<TDataType>) => void;\n\n/**\n * Represents the connection for an observable query.\n */\nexport class ObservableQueryConnection<TDataType> implements IObservableQueryConnection<TDataType> {\n\n private _socket!: WebSocket;\n private _disconnected = false;\n private _url: string;\n private _pingInterval?: ReturnType<typeof setInterval>;\n private _pingIntervalMs: number = 10000;\n private _lastPingSentTime?: number;\n private _lastPongLatency: number = 0;\n private _latencySamples: number[] = [];\n private _connectionStartTime?: number;\n\n /**\n * Initializes a new instance of the {@link ObservableQueryConnection<TDataType>} class.\n * @param {Url} url The fully qualified Url.\n * @param {string} _microservice The microservice name.\n * @param {number} pingIntervalMs The ping interval in milliseconds (default: 10000).\n */\n constructor(url: URL, private readonly _microservice: string, pingIntervalMs: number = 10000) {\n this._pingIntervalMs = pingIntervalMs;\n const secure = url.protocol?.indexOf('https') === 0 || false;\n\n this._url = `${secure ? 'wss' : 'ws'}://${url.host}${url.pathname}${url.search}`;\n if (this._microservice?.length > 0) {\n const microserviceParam = `${Globals.microserviceWSQueryArgument}=${this._microservice}`;\n if (this._url.indexOf('?') > 0) {\n this._url = `${this._url}&${microserviceParam}`;\n } else {\n this._url = `${this._url}?${microserviceParam}`;\n }\n }\n }\n\n /**\n * Disposes the connection.\n */\n dispose() {\n this.disconnect();\n }\n\n /**\n * Gets the latency of the last ping/pong sequence in milliseconds.\n */\n get lastPingLatency(): number {\n return this._lastPongLatency;\n }\n\n /**\n * Gets the average latency since the connection started in milliseconds.\n */\n get averageLatency(): number {\n if (this._latencySamples.length === 0) {\n return 0;\n }\n const sum = this._latencySamples.reduce((acc, val) => acc + val, 0);\n return sum / this._latencySamples.length;\n }\n\n /** @inheritdoc */\n connect(dataReceived: DataReceived<TDataType>, queryArguments?: object) {\n let url = this._url;\n if (queryArguments) {\n if (url.indexOf('?') < 0) {\n url = `${url}?`;\n } else {\n url = `${url}&`;\n }\n const query = Object.keys(queryArguments).map(key => `${key}=${queryArguments[key]}`).join('&');\n url = `${url}${query}`;\n }\n\n let timeToWait = 500;\n const timeExponent = 500;\n const retries = 100;\n let currentAttempt = 0;\n const maxTime = 10_000;\n\n const connectSocket = () => {\n const retry = () => {\n currentAttempt++;\n if (currentAttempt > retries) {\n console.log(`Attempted ${retries} retries for route '${url}'. Abandoning.`);\n return;\n }\n console.log(`Attempting to reconnect for '${url}' (#${currentAttempt})`);\n\n setTimeout(connectSocket, timeToWait);\n timeToWait += (timeExponent * currentAttempt);\n timeToWait = timeToWait > maxTime ? maxTime : timeToWait; \n };\n\n this._socket = new WebSocket(url);\n this._socket.onopen = () => {\n if (this._disconnected) return;\n console.log(`Connection for '${url}' established`);\n timeToWait = 500;\n currentAttempt = 0;\n this._connectionStartTime = Date.now();\n this.startPinging();\n };\n this._socket.onclose = () => {\n if (this._disconnected) return;\n console.log(`Unexpected connection closed for route '${url}'`);\n this.stopPinging();\n retry();\n };\n this._socket.onerror = (error) => {\n if (this._disconnected) return;\n console.log(`Error with connection for '${url}' - ${error}`);\n this.stopPinging();\n retry();\n };\n this._socket.onmessage = (ev) => {\n if (this._disconnected) {\n console.log('Received message after closing connection');\n return;\n }\n this.handleMessage(ev.data, dataReceived);\n };\n };\n\n if (this._disconnected) return;\n connectSocket();\n }\n\n /** @inheritdoc */\n disconnect() {\n if (this._disconnected) {\n return;\n }\n console.log(`Disconnecting '${this._url}'`);\n this._disconnected = true;\n this.stopPinging();\n this._socket?.close();\n console.log(`Connection for '${this._url}' closed`);\n this._socket = undefined!;\n }\n\n private startPinging() {\n this.stopPinging();\n this._pingInterval = setInterval(() => {\n this.sendPing();\n }, this._pingIntervalMs);\n }\n\n private stopPinging() {\n if (this._pingInterval) {\n clearInterval(this._pingInterval);\n this._pingInterval = undefined;\n }\n }\n\n private sendPing() {\n if (this._disconnected || !this._socket || this._socket.readyState !== WebSocket.OPEN) {\n return;\n }\n\n this._lastPingSentTime = Date.now();\n const pingMessage: WebSocketMessage = {\n type: WebSocketMessageType.Ping,\n timestamp: this._lastPingSentTime\n };\n\n this._socket.send(JSON.stringify(pingMessage));\n }\n\n private handleMessage(rawData: string, dataReceived: DataReceived<TDataType>) {\n try {\n const message = JSON.parse(rawData) as WebSocketMessage;\n\n // Handle messages based on type\n if (message.type === WebSocketMessageType.Pong) {\n this.handlePong(message);\n } else if (message.type === WebSocketMessageType.Data || !message.type) {\n // For backward compatibility, treat messages without a type as data messages\n const data = message.data ?? message;\n dataReceived(data as QueryResult<TDataType>);\n }\n } catch (error) {\n console.error('Error parsing WebSocket message:', error);\n }\n }\n\n private handlePong(message: WebSocketMessage) {\n if (message.timestamp && this._lastPingSentTime) {\n const latency = Date.now() - message.timestamp;\n this._lastPongLatency = latency;\n this._latencySamples.push(latency);\n\n // Keep only the last 100 samples for average calculation\n if (this._latencySamples.length > 100) {\n this._latencySamples.shift();\n }\n }\n }\n}\n"],"names":["Globals","WebSocketMessageType"],"mappings":";;;;;MAaa,yBAAyB,CAAA;AAkBK,IAAA,aAAA;AAhB/B,IAAA,OAAO;IACP,aAAa,GAAG,KAAK;AACrB,IAAA,IAAI;AACJ,IAAA,aAAa;IACb,eAAe,GAAW,KAAK;AAC/B,IAAA,iBAAiB;IACjB,gBAAgB,GAAW,CAAC;IAC5B,eAAe,GAAa,EAAE;AAC9B,IAAA,oBAAoB;AAQ5B,IAAA,WAAA,CAAY,GAAQ,EAAmB,aAAqB,EAAE,iBAAyB,KAAK,EAAA;QAArD,IAAA,CAAA,aAAa,GAAb,aAAa;AAChD,QAAA,IAAI,CAAC,eAAe,GAAG,cAAc;AACrC,QAAA,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK;QAE5D,IAAI,CAAC,IAAI,GAAG,CAAA,EAAG,MAAM,GAAG,KAAK,GAAG,IAAI,MAAM,GAAG,CAAC,IAAI,CAAA,EAAG,GAAG,CAAC,QAAQ,CAAA,EAAG,GAAG,CAAC,MAAM,CAAA,CAAE;QAChF,IAAI,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,CAAC,EAAE;YAChC,MAAM,iBAAiB,GAAG,CAAA,EAAGA,eAAO,CAAC,2BAA2B,CAAA,CAAA,EAAI,IAAI,CAAC,aAAa,CAAA,CAAE;YACxF,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBAC5B,IAAI,CAAC,IAAI,GAAG,CAAA,EAAG,IAAI,CAAC,IAAI,CAAA,CAAA,EAAI,iBAAiB,CAAA,CAAE;YACnD;iBAAO;gBACH,IAAI,CAAC,IAAI,GAAG,CAAA,EAAG,IAAI,CAAC,IAAI,CAAA,CAAA,EAAI,iBAAiB,CAAA,CAAE;YACnD;QACJ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IAAI,CAAC,gBAAgB,GAAG,OAAO;AAC/B,YAAA,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;YAGlC,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,GAAG,EAAE;AACnC,gBAAA,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE;YAChC;QACJ;IACJ;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"ObservableQueryConnection.js","sources":["../../../queries/ObservableQueryConnection.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Globals } from '../Globals';\nimport { IObservableQueryConnection } from './IObservableQueryConnection';\nimport { IReconnectPolicy } from './IReconnectPolicy';\nimport { ReconnectPolicy } from './ReconnectPolicy';\nimport { QueryResult } from './QueryResult';\nimport { WebSocketMessage, WebSocketMessageType } from './WebSocketMessage';\n\nexport type DataReceived<TDataType> = (data: QueryResult<TDataType>) => void;\n\n/**\n * Represents the connection for an observable query.\n */\nexport class ObservableQueryConnection<TDataType> implements IObservableQueryConnection<TDataType> {\n\n private _socket!: WebSocket;\n private _disconnected = false;\n private _url: string;\n private _pingInterval?: ReturnType<typeof setInterval>;\n private _pingIntervalMs: number = 10000;\n private _lastPingSentTime?: number;\n private _lastPongLatency: number = 0;\n private _latencySamples: number[] = [];\n private _connectionStartTime?: number;\n\n /**\n * Initializes a new instance of the {@link ObservableQueryConnection<TDataType>} class.\n * @param {Url} url The fully qualified Url.\n * @param {string} _microservice The microservice name.\n * @param {number} pingIntervalMs The ping interval in milliseconds (default: 10000).\n * @param {IReconnectPolicy} reconnectPolicy The reconnect policy to use (default: {@link ReconnectPolicy}).\n */\n constructor(url: URL, private readonly _microservice: string, pingIntervalMs: number = 10000, private readonly _reconnectPolicy: IReconnectPolicy = new ReconnectPolicy()) {\n this._pingIntervalMs = pingIntervalMs;\n const secure = url.protocol?.indexOf('https') === 0 || false;\n\n this._url = `${secure ? 'wss' : 'ws'}://${url.host}${url.pathname}${url.search}`;\n if (this._microservice?.length > 0) {\n const microserviceParam = `${Globals.microserviceWSQueryArgument}=${this._microservice}`;\n if (this._url.indexOf('?') > 0) {\n this._url = `${this._url}&${microserviceParam}`;\n } else {\n this._url = `${this._url}?${microserviceParam}`;\n }\n }\n }\n\n /**\n * Disposes the connection.\n */\n dispose() {\n this.disconnect();\n }\n\n /**\n * Gets the latency of the last ping/pong sequence in milliseconds.\n */\n get lastPingLatency(): number {\n return this._lastPongLatency;\n }\n\n /**\n * Gets the average latency since the connection started in milliseconds.\n */\n get averageLatency(): number {\n if (this._latencySamples.length === 0) {\n return 0;\n }\n const sum = this._latencySamples.reduce((acc, val) => acc + val, 0);\n return sum / this._latencySamples.length;\n }\n\n /** @inheritdoc */\n connect(dataReceived: DataReceived<TDataType>, queryArguments?: object) {\n let url = this._url;\n if (queryArguments) {\n if (url.indexOf('?') < 0) {\n url = `${url}?`;\n } else {\n url = `${url}&`;\n }\n const query = Object.keys(queryArguments).map(key => `${key}=${queryArguments[key]}`).join('&');\n url = `${url}${query}`;\n }\n\n const connectSocket = () => {\n this._socket = new WebSocket(url);\n this._socket.onopen = () => {\n if (this._disconnected) return;\n console.log(`Connection for '${url}' established`);\n this._reconnectPolicy.reset();\n this._connectionStartTime = Date.now();\n this.startPinging();\n };\n this._socket.onclose = () => {\n if (this._disconnected) return;\n console.log(`Unexpected connection closed for route '${url}'`);\n this.stopPinging();\n this._reconnectPolicy.schedule(connectSocket, url);\n };\n this._socket.onerror = (error) => {\n if (this._disconnected) return;\n console.log(`Error with connection for '${url}' - ${error}`);\n this.stopPinging();\n this._reconnectPolicy.schedule(connectSocket, url);\n };\n this._socket.onmessage = (ev) => {\n if (this._disconnected) {\n console.log('Received message after closing connection');\n return;\n }\n this.handleMessage(ev.data, dataReceived);\n };\n };\n\n if (this._disconnected) return;\n connectSocket();\n }\n\n /** @inheritdoc */\n disconnect() {\n if (this._disconnected) {\n return;\n }\n console.log(`Disconnecting '${this._url}'`);\n this._disconnected = true;\n this._reconnectPolicy.cancel();\n this.stopPinging();\n this._socket?.close();\n console.log(`Connection for '${this._url}' closed`);\n this._socket = undefined!;\n }\n\n private startPinging() {\n this.stopPinging();\n this._pingInterval = setInterval(() => {\n this.sendPing();\n }, this._pingIntervalMs);\n }\n\n private stopPinging() {\n if (this._pingInterval) {\n clearInterval(this._pingInterval);\n this._pingInterval = undefined;\n }\n }\n\n private sendPing() {\n if (this._disconnected || !this._socket || this._socket.readyState !== WebSocket.OPEN) {\n return;\n }\n\n this._lastPingSentTime = Date.now();\n const pingMessage: WebSocketMessage = {\n type: WebSocketMessageType.Ping,\n timestamp: this._lastPingSentTime\n };\n\n this._socket.send(JSON.stringify(pingMessage));\n }\n\n private handleMessage(rawData: string, dataReceived: DataReceived<TDataType>) {\n try {\n const message = JSON.parse(rawData) as WebSocketMessage;\n\n // Handle messages based on type\n if (message.type === WebSocketMessageType.Pong) {\n this.handlePong(message);\n } else if (message.type === WebSocketMessageType.Data || !message.type) {\n // For backward compatibility, treat messages without a type as data messages\n const data = message.data ?? message;\n dataReceived(data as QueryResult<TDataType>);\n }\n } catch (error) {\n console.error('Error parsing WebSocket message:', error);\n }\n }\n\n private handlePong(message: WebSocketMessage) {\n if (message.timestamp && this._lastPingSentTime) {\n const latency = Date.now() - message.timestamp;\n this._lastPongLatency = latency;\n this._latencySamples.push(latency);\n\n // Keep only the last 100 samples for average calculation\n if (this._latencySamples.length > 100) {\n this._latencySamples.shift();\n }\n }\n }\n}\n"],"names":["ReconnectPolicy","Globals","WebSocketMessageType"],"mappings":";;;;;;MAea,yBAAyB,CAAA;AAmBK,IAAA,aAAA;AAAwE,IAAA,gBAAA;AAjBvG,IAAA,OAAO;IACP,aAAa,GAAG,KAAK;AACrB,IAAA,IAAI;AACJ,IAAA,aAAa;IACb,eAAe,GAAW,KAAK;AAC/B,IAAA,iBAAiB;IACjB,gBAAgB,GAAW,CAAC;IAC5B,eAAe,GAAa,EAAE;AAC9B,IAAA,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AAO,CAAC,IAAI,KAAKA,qCAAoB,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;AAEpE,gBAAA,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO;gBACpC,YAAY,CAAC,IAA8B,CAAC;YAChD;QACJ;QAAE,OAAO,KAAK,EAAE;AACZ,YAAA,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC;QAC5D;IACJ;AAEQ,IAAA,UAAU,CAAC,OAAyB,EAAA;QACxC,IAAI,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,SAAS;AAC9C,YAAA,IAAI,CAAC,gBAAgB,GAAG,OAAO;AAC/B,YAAA,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;YAGlC,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,GAAG,EAAE;AACnC,gBAAA,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE;YAChC;QACJ;IACJ;AACH;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IObservableQueryConnection } from './IObservableQueryConnection';
|
|
2
|
+
export declare const SSE_SUBSCRIBE_ROUTE = "/.cratis/queries/sse/subscribe";
|
|
3
|
+
export declare const SSE_UNSUBSCRIBE_ROUTE = "/.cratis/queries/sse/unsubscribe";
|
|
4
|
+
export interface QueryConnectionDescriptor {
|
|
5
|
+
route: string;
|
|
6
|
+
queryName: string;
|
|
7
|
+
origin: string;
|
|
8
|
+
apiBasePath: string;
|
|
9
|
+
microservice: string;
|
|
10
|
+
args?: object;
|
|
11
|
+
}
|
|
12
|
+
export declare function createObservableQueryConnection<TDataType>(descriptor: QueryConnectionDescriptor): IObservableQueryConnection<TDataType>;
|
|
13
|
+
//# sourceMappingURL=ObservableQueryConnectionFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservableQueryConnectionFactory.d.ts","sourceRoot":"","sources":["../../../queries/ObservableQueryConnectionFactory.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAW1E,eAAO,MAAM,mBAAmB,mCAAmC,CAAC;AAKpE,eAAO,MAAM,qBAAqB,qCAAqC,CAAC;AAOxE,MAAM,WAAW,yBAAyB;IAEtC,KAAK,EAAE,MAAM,CAAC;IAEd,SAAS,EAAE,MAAM,CAAC;IAElB,MAAM,EAAE,MAAM,CAAC;IAEf,WAAW,EAAE,MAAM,CAAC;IAEpB,YAAY,EAAE,MAAM,CAAC;IAErB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAiBD,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,UAAU,EAAE,yBAAyB,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAUvI"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Globals = require('../Globals.js');
|
|
4
|
+
var joinPaths = require('../joinPaths.js');
|
|
5
|
+
var UrlHelpers = require('../UrlHelpers.js');
|
|
6
|
+
var ObservableQueryConnection = require('./ObservableQueryConnection.js');
|
|
7
|
+
var QueryTransportMethod = require('./QueryTransportMethod.js');
|
|
8
|
+
var ServerSentEventQueryConnection = require('./ServerSentEventQueryConnection.js');
|
|
9
|
+
var ServerSentEventHubConnection = require('./ServerSentEventHubConnection.js');
|
|
10
|
+
var WebSocketHubConnection = require('./WebSocketHubConnection.js');
|
|
11
|
+
var ObservableQueryMultiplexer = require('./ObservableQueryMultiplexer.js');
|
|
12
|
+
|
|
13
|
+
const SSE_SUBSCRIBE_ROUTE = '/.cratis/queries/sse/subscribe';
|
|
14
|
+
const SSE_UNSUBSCRIBE_ROUTE = '/.cratis/queries/sse/unsubscribe';
|
|
15
|
+
function createObservableQueryConnection(descriptor) {
|
|
16
|
+
const isSSE = Globals.Globals.queryTransportMethod === QueryTransportMethod.QueryTransportMethod.ServerSentEvents;
|
|
17
|
+
if (Globals.Globals.queryDirectMode) {
|
|
18
|
+
return isSSE
|
|
19
|
+
? createDirectSSEConnection(descriptor)
|
|
20
|
+
: createDirectWebSocketConnection(descriptor);
|
|
21
|
+
}
|
|
22
|
+
return createMultiplexedConnection(descriptor, isSSE);
|
|
23
|
+
}
|
|
24
|
+
function buildDirectUrl(descriptor) {
|
|
25
|
+
const { route } = UrlHelpers.UrlHelpers.replaceRouteParameters(descriptor.route, descriptor.args);
|
|
26
|
+
const actualRoute = joinPaths.joinPaths(descriptor.apiBasePath, route);
|
|
27
|
+
return UrlHelpers.UrlHelpers.createUrlFrom(descriptor.origin, descriptor.apiBasePath, actualRoute);
|
|
28
|
+
}
|
|
29
|
+
function createDirectWebSocketConnection(descriptor) {
|
|
30
|
+
return new ObservableQueryConnection.ObservableQueryConnection(buildDirectUrl(descriptor), descriptor.microservice);
|
|
31
|
+
}
|
|
32
|
+
function createDirectSSEConnection(descriptor) {
|
|
33
|
+
return new ServerSentEventQueryConnection.ServerSentEventQueryConnection(buildDirectUrl(descriptor));
|
|
34
|
+
}
|
|
35
|
+
function createMultiplexedConnection(descriptor, isSSE) {
|
|
36
|
+
const transport = isSSE ? 'sse' : 'ws';
|
|
37
|
+
const cacheKey = `${Globals.Globals.queryConnectionCount}|${transport}|${descriptor.origin}|${descriptor.apiBasePath}|${descriptor.microservice}`;
|
|
38
|
+
const multiplexer = ObservableQueryMultiplexer.getOrCreateMultiplexer(() => {
|
|
39
|
+
if (isSSE) {
|
|
40
|
+
const sseRoute = joinPaths.joinPaths(descriptor.apiBasePath, ServerSentEventQueryConnection.SSE_HUB_ROUTE);
|
|
41
|
+
const sseUrl = UrlHelpers.UrlHelpers.createUrlFrom(descriptor.origin, descriptor.apiBasePath, sseRoute);
|
|
42
|
+
const subscribeRoute = joinPaths.joinPaths(descriptor.apiBasePath, SSE_SUBSCRIBE_ROUTE);
|
|
43
|
+
const subscribeUrl = UrlHelpers.UrlHelpers.createUrlFrom(descriptor.origin, descriptor.apiBasePath, subscribeRoute);
|
|
44
|
+
const unsubscribeRoute = joinPaths.joinPaths(descriptor.apiBasePath, SSE_UNSUBSCRIBE_ROUTE);
|
|
45
|
+
const unsubscribeUrl = UrlHelpers.UrlHelpers.createUrlFrom(descriptor.origin, descriptor.apiBasePath, unsubscribeRoute);
|
|
46
|
+
return new ServerSentEventHubConnection.ServerSentEventHubConnection(sseUrl.toString(), subscribeUrl.toString(), unsubscribeUrl.toString(), descriptor.microservice);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const hubRoute = joinPaths.joinPaths(descriptor.apiBasePath, ObservableQueryMultiplexer.WS_HUB_ROUTE);
|
|
50
|
+
const hubUrl = UrlHelpers.UrlHelpers.createUrlFrom(descriptor.origin, descriptor.apiBasePath, hubRoute);
|
|
51
|
+
const secure = hubUrl.protocol?.indexOf('https') === 0;
|
|
52
|
+
const wsUrl = `${secure ? 'wss' : 'ws'}://${hubUrl.host}${hubUrl.pathname}${hubUrl.search}`;
|
|
53
|
+
return new WebSocketHubConnection.WebSocketHubConnection(wsUrl, descriptor.microservice);
|
|
54
|
+
}
|
|
55
|
+
}, cacheKey);
|
|
56
|
+
return new ObservableQueryMultiplexer.MultiplexedObservableQueryConnection(multiplexer, descriptor.queryName);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.SSE_SUBSCRIBE_ROUTE = SSE_SUBSCRIBE_ROUTE;
|
|
60
|
+
exports.SSE_UNSUBSCRIBE_ROUTE = SSE_UNSUBSCRIBE_ROUTE;
|
|
61
|
+
exports.createObservableQueryConnection = createObservableQueryConnection;
|
|
62
|
+
//# sourceMappingURL=ObservableQueryConnectionFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservableQueryConnectionFactory.js","sources":["../../../queries/ObservableQueryConnectionFactory.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Globals } from '../Globals';\nimport { joinPaths } from '../joinPaths';\nimport { UrlHelpers } from '../UrlHelpers';\nimport { IObservableQueryConnection } from './IObservableQueryConnection';\nimport { ObservableQueryConnection } from './ObservableQueryConnection';\nimport { QueryTransportMethod } from './QueryTransportMethod';\nimport { ServerSentEventQueryConnection, SSE_HUB_ROUTE } from './ServerSentEventQueryConnection';\nimport { ServerSentEventHubConnection } from './ServerSentEventHubConnection';\nimport { WebSocketHubConnection } from './WebSocketHubConnection';\nimport { MultiplexedObservableQueryConnection, WS_HUB_ROUTE, getOrCreateMultiplexer } from './ObservableQueryMultiplexer';\n\n/**\n * The SSE subscribe POST endpoint route.\n */\nexport const SSE_SUBSCRIBE_ROUTE = '/.cratis/queries/sse/subscribe';\n\n/**\n * The SSE unsubscribe POST endpoint route.\n */\nexport const SSE_UNSUBSCRIBE_ROUTE = '/.cratis/queries/sse/unsubscribe';\n\n/**\n * Describes what the factory needs to know about a query in order to create\n * the right connection. Transport details are intentionally absent — the\n * factory reads those from {@link Globals}.\n */\nexport interface QueryConnectionDescriptor {\n /** The route template (e.g. `/api/accounts/debit/all-accounts`). */\n route: string;\n /** Fully-qualified backend query name used by hub transports. */\n queryName: string;\n /** Origin base URL (e.g. `http://localhost:5000`). */\n origin: string;\n /** API base path prefix. */\n apiBasePath: string;\n /** Microservice identifier. */\n microservice: string;\n /** Route/query arguments for the current subscription. */\n args?: object;\n}\n\n/**\n * Single entry-point for creating observable query connections.\n *\n * The transport is chosen as a 2x2 matrix of (direct | hub) x (WebSocket | SSE):\n *\n * | | Direct (per-query URL) | Hub (centralized endpoint) |\n * |----------------|-------------------------------|-------------------------------|\n * | **WebSocket** | ObservableQueryConnection | MultiplexedObservableQueryConnection |\n * | **SSE** | ServerSentEventQueryConnection | MultiplexedObservableQueryConnection |\n *\n * In multiplexed mode, both transports share the same multiplexer — it creates either\n * WebSocket or SSE connections depending on the transport setting.\n *\n * {@link ObservableQueryFor} never needs to know which transport is in use.\n */\nexport function createObservableQueryConnection<TDataType>(descriptor: QueryConnectionDescriptor): IObservableQueryConnection<TDataType> {\n const isSSE = Globals.queryTransportMethod === QueryTransportMethod.ServerSentEvents;\n\n if (Globals.queryDirectMode) {\n return isSSE\n ? createDirectSSEConnection<TDataType>(descriptor)\n : createDirectWebSocketConnection<TDataType>(descriptor);\n }\n\n return createMultiplexedConnection<TDataType>(descriptor, isSSE);\n}\n\n// ---- Direct mode: one connection per query, hitting the query's own URL ----\n\nfunction buildDirectUrl(descriptor: QueryConnectionDescriptor): URL {\n const { route } = UrlHelpers.replaceRouteParameters(descriptor.route, descriptor.args as object);\n const actualRoute = joinPaths(descriptor.apiBasePath, route);\n return UrlHelpers.createUrlFrom(descriptor.origin, descriptor.apiBasePath, actualRoute);\n}\n\nfunction createDirectWebSocketConnection<TDataType>(descriptor: QueryConnectionDescriptor): IObservableQueryConnection<TDataType> {\n return new ObservableQueryConnection<TDataType>(buildDirectUrl(descriptor), descriptor.microservice);\n}\n\nfunction createDirectSSEConnection<TDataType>(descriptor: QueryConnectionDescriptor): IObservableQueryConnection<TDataType> {\n return new ServerSentEventQueryConnection<TDataType>(buildDirectUrl(descriptor));\n}\n\n// ---- Multiplexed mode: centralized endpoint, multiple queries share connections ----\n\nfunction createMultiplexedConnection<TDataType>(descriptor: QueryConnectionDescriptor, isSSE: boolean): IObservableQueryConnection<TDataType> {\n const transport = isSSE ? 'sse' : 'ws';\n const cacheKey = `${Globals.queryConnectionCount}|${transport}|${descriptor.origin}|${descriptor.apiBasePath}|${descriptor.microservice}`;\n\n const multiplexer = getOrCreateMultiplexer(() => {\n if (isSSE) {\n const sseRoute = joinPaths(descriptor.apiBasePath, SSE_HUB_ROUTE);\n const sseUrl = UrlHelpers.createUrlFrom(descriptor.origin, descriptor.apiBasePath, sseRoute);\n const subscribeRoute = joinPaths(descriptor.apiBasePath, SSE_SUBSCRIBE_ROUTE);\n const subscribeUrl = UrlHelpers.createUrlFrom(descriptor.origin, descriptor.apiBasePath, subscribeRoute);\n const unsubscribeRoute = joinPaths(descriptor.apiBasePath, SSE_UNSUBSCRIBE_ROUTE);\n const unsubscribeUrl = UrlHelpers.createUrlFrom(descriptor.origin, descriptor.apiBasePath, unsubscribeRoute);\n return new ServerSentEventHubConnection(\n sseUrl.toString(),\n subscribeUrl.toString(),\n unsubscribeUrl.toString(),\n descriptor.microservice,\n );\n } else {\n const hubRoute = joinPaths(descriptor.apiBasePath, WS_HUB_ROUTE);\n const hubUrl = UrlHelpers.createUrlFrom(descriptor.origin, descriptor.apiBasePath, hubRoute);\n const secure = hubUrl.protocol?.indexOf('https') === 0;\n const wsUrl = `${secure ? 'wss' : 'ws'}://${hubUrl.host}${hubUrl.pathname}${hubUrl.search}`;\n return new WebSocketHubConnection(wsUrl, descriptor.microservice);\n }\n }, cacheKey);\n\n return new MultiplexedObservableQueryConnection<TDataType>(multiplexer, descriptor.queryName);\n}\n"],"names":["Globals","QueryTransportMethod","UrlHelpers","joinPaths","ObservableQueryConnection","ServerSentEventQueryConnection","getOrCreateMultiplexer","SSE_HUB_ROUTE","ServerSentEventHubConnection","WS_HUB_ROUTE","WebSocketHubConnection","MultiplexedObservableQueryConnection"],"mappings":";;;;;;;;;;;;AAiBO,MAAM,mBAAmB,GAAG;AAK5B,MAAM,qBAAqB,GAAG;AAqC/B,SAAU,+BAA+B,CAAY,UAAqC,EAAA;IAC5F,MAAM,KAAK,GAAGA,eAAO,CAAC,oBAAoB,KAAKC,yCAAoB,CAAC,gBAAgB;AAEpF,IAAA,IAAID,eAAO,CAAC,eAAe,EAAE;AACzB,QAAA,OAAO;AACH,cAAE,yBAAyB,CAAY,UAAU;AACjD,cAAE,+BAA+B,CAAY,UAAU,CAAC;IAChE;AAEA,IAAA,OAAO,2BAA2B,CAAY,UAAU,EAAE,KAAK,CAAC;AACpE;AAIA,SAAS,cAAc,CAAC,UAAqC,EAAA;AACzD,IAAA,MAAM,EAAE,KAAK,EAAE,G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CAAC,MAAM,EAAE,UAAU,CAAC,WAAW,EAAE,cAAc,CAAC;YACxG,MAAM,gBAAgB,GAAGC,mBAAS,CAAC,UAAU,CAAC,WAAW,EAAE,qBAAqB,CAAC;AACjF,YAAA,MAAM,cAAc,GAAGD,qBAAU,CAAC,aAAa,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,WAAW,EAAE,gBAAgB,CAAC;YAC5G,OAAO,IAAIM,yDAA4B,CACnC,MAAM,CAAC,QAAQ,EAAE,EACjB,YAAY,CAAC,QAAQ,EAAE,EACvB,cAAc,CAAC,QAAQ,EAAE,EACzB,UAAU,CAAC,YAAY,CAC1B;QACL;aAAO;YACH,MAAM,QAAQ,GAAGL,mBAAS,CAAC,UAAU,CAAC,WAAW,EAAEM,uCAAY,CAAC;AAChE,YAAA,MAAM,MAAM,GAAGP,qBAAU,CAAC,aAAa,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,WAAW,EAAE,QAAQ,CAAC;AAC5F,YAAA,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;YACtD,MAAM,KAAK,GAAG,CAAA,EAAG,MAAM,GAAG,KAAK,GAAG,IAAI,MAAM,MAAM,CAAC,IAAI,CAAA,EAAG,MAAM,CAAC,QAAQ,CAAA,EAAG,MAAM,CAAC,MAAM,CAAA,CAAE;YAC3F,OAAO,IAAIQ,6CAAsB,CAAC,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC;QACrE;IACJ,CAAC,EAAE,QAAQ,CAAC;IAEZ,OAAO,IAAIC,+DAAoC,CAAY,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC;AACjG;;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IObservableQueryConnection } from './IObservableQueryConnection';
|
|
2
|
+
import { DataReceived } from './ObservableQueryConnection';
|
|
3
|
+
export declare class ObservableQueryConnectionPool<TDataType> {
|
|
4
|
+
private readonly _factory;
|
|
5
|
+
private readonly _slots;
|
|
6
|
+
constructor(size: number, _factory: () => IObservableQueryConnection<TDataType>);
|
|
7
|
+
acquire(dataReceived: DataReceived<TDataType>, queryArguments?: object): () => void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=ObservableQueryConnectionPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservableQueryConnectionPool.d.ts","sourceRoot":"","sources":["../../../queries/ObservableQueryConnectionPool.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAuB3D,qBAAa,6BAA6B,CAAC,SAAS;IAU5C,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAT7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;gBAQhC,IAAI,EAAE,MAAM,EACK,QAAQ,EAAE,MAAM,0BAA0B,CAAC,SAAS,CAAC;IAY1E,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,IAAI;CActF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
class ObservableQueryConnectionPool {
|
|
4
|
+
_factory;
|
|
5
|
+
_slots;
|
|
6
|
+
constructor(size, _factory) {
|
|
7
|
+
this._factory = _factory;
|
|
8
|
+
this._slots = Array.from({ length: Math.max(1, size) }, () => ({ queryCount: 0 }));
|
|
9
|
+
}
|
|
10
|
+
acquire(dataReceived, queryArguments) {
|
|
11
|
+
const slot = this._slots.reduce((min, current) => current.queryCount < min.queryCount ? current : min, this._slots[0]);
|
|
12
|
+
slot.queryCount++;
|
|
13
|
+
const connection = this._factory();
|
|
14
|
+
connection.connect(dataReceived, queryArguments);
|
|
15
|
+
return () => {
|
|
16
|
+
connection.disconnect();
|
|
17
|
+
slot.queryCount = Math.max(0, slot.queryCount - 1);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.ObservableQueryConnectionPool = ObservableQueryConnectionPool;
|
|
23
|
+
//# sourceMappingURL=ObservableQueryConnectionPool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservableQueryConnectionPool.js","sources":["../../../queries/ObservableQueryConnectionPool.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IObservableQueryConnection } from './IObservableQueryConnection';\nimport { DataReceived } from './ObservableQueryConnection';\n\n/**\n * Tracks the number of active subscribers assigned to each pool slot.\n */\ninterface PoolSlot {\n queryCount: number;\n}\n\n/**\n * Represents a pool of observable query connection factories distributed round-robin across N slots.\n *\n * Each call to {@link acquire} picks the slot with the fewest active queries (falling back to\n * round-robin when counts are equal) and creates a fresh connection for that subscriber via the\n * provided factory. The connection is a dedicated instance per subscriber; the pool only tracks\n * slot utilization so future multiplexed transports (e.g. WebSocket) can share connections\n * across a fixed number of physical hub connections.\n *\n * When {@link size} is 1 (the default), all queries are counted against a single slot — the\n * natural behavior for a single multiplexed connection.\n *\n * @template TDataType The type of data received from the connections.\n */\nexport class ObservableQueryConnectionPool<TDataType> {\n private readonly _slots: PoolSlot[];\n\n /**\n * Initializes a new {@link ObservableQueryConnectionPool}.\n * @param {number} size Number of logical slots (hub connections) in the pool.\n * @param {() => IObservableQueryConnection<TDataType>} factory Factory that produces a new connection instance per subscriber.\n */\n constructor(\n size: number,\n private readonly _factory: () => IObservableQueryConnection<TDataType>\n ) {\n this._slots = Array.from({ length: Math.max(1, size) }, () => ({ queryCount: 0 }));\n }\n\n /**\n * Picks the least-loaded pool slot, creates a fresh connection via the factory, and starts\n * delivering data to the provided callback.\n * @param {DataReceived<TDataType>} dataReceived Callback invoked for each message.\n * @param {object} queryArguments Arguments forwarded to the connection.\n * @returns A cleanup function that decrements the slot counter and disconnects the connection.\n */\n acquire(dataReceived: DataReceived<TDataType>, queryArguments?: object): () => void {\n // Pick the slot with the fewest active queries.\n const slot = this._slots.reduce((min, current) => current.queryCount < min.queryCount ? current : min, this._slots[0]);\n slot.queryCount++;\n\n // Each subscriber gets its own dedicated connection instance.\n const connection = this._factory();\n connection.connect(dataReceived, queryArguments);\n\n return () => {\n connection.disconnect();\n slot.queryCount = Math.max(0, slot.queryCount - 1);\n };\n }\n}\n"],"names":[],"mappings":";;MA2Ba,6BAA6B,CAAA;AAUjB,IAAA,QAAA;AATJ,IAAA,MAAM;IAOvB,WAAA,CACI,IAAY,EACK,QAAqD,EAAA;QAArD,IAAA,CAAA,QAAQ,GAAR,QAAQ;AAEzB,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;IACtF;IASA,OAAO,CAAC,YAAqC,EAAE,cAAuB,EAAA;AAElE,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,GAAG,OAAO,GAAG,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACtH,IAAI,CAAC,UAAU,EAAE;AAGjB,QAAA,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE;AAClC,QAAA,UAAU,CAAC,OAAO,CAAC,YAAY,EAAE,cAAc,CAAC;AAEhD,QAAA,OAAO,MAAK;YACR,UAAU,CAAC,UAAU,EAAE;AACvB,YAAA,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;AACtD,QAAA,CAAC;IACL;AACH;;;;"}
|
|
@@ -17,6 +17,7 @@ export declare abstract class ObservableQueryFor<TDataType, TParameters = object
|
|
|
17
17
|
abstract readonly route: string;
|
|
18
18
|
abstract readonly defaultValue: TDataType;
|
|
19
19
|
readonly roles: string[];
|
|
20
|
+
readonly queryName?: string;
|
|
20
21
|
abstract readonly parameterDescriptors: ParameterDescriptor[];
|
|
21
22
|
abstract get requiredRequestParameters(): string[];
|
|
22
23
|
sorting: Sorting;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableQueryFor.d.ts","sourceRoot":"","sources":["../../../queries/ObservableQueryFor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ObservableQueryFor.d.ts","sourceRoot":"","sources":["../../../queries/ObservableQueryFor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAK5E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKlC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AASxE,8BAAsB,kBAAkB,CAAC,SAAS,EAAE,WAAW,GAAG,MAAM,CAAE,YAAW,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC;IAsBhH,QAAQ,CAAC,SAAS,EAAE,WAAW;IAAE,QAAQ,CAAC,UAAU,EAAE,OAAO;IArBzE,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,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ySubscription.js');
|
|
5
4
|
var ValidateRequestArguments = require('./ValidateRequestArguments.js');
|
|
6
5
|
var NullObservableQueryConnection = require('./NullObservableQueryConnection.js');
|
|
6
|
+
var ObservableQueryConnectionFactory = require('./ObservableQueryConnectionFactory.js');
|
|
7
7
|
var fundamentals = require('@cratis/fundamentals');
|
|
8
8
|
var QueryResult = require('./QueryResult.js');
|
|
9
9
|
var Sorting = require('./Sorting.js');
|
|
@@ -23,6 +23,7 @@ class ObservableQueryFor {
|
|
|
23
23
|
_connection;
|
|
24
24
|
_httpHeadersCallback;
|
|
25
25
|
roles = [];
|
|
26
|
+
queryName;
|
|
26
27
|
sorting;
|
|
27
28
|
paging;
|
|
28
29
|
constructor(modelType, enumerable) {
|
|
@@ -58,10 +59,14 @@ class ObservableQueryFor {
|
|
|
58
59
|
this._connection = new NullObservableQueryConnection.NullObservableQueryConnection(this.defaultValue);
|
|
59
60
|
}
|
|
60
61
|
else {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
this._connection = ObservableQueryConnectionFactory.createObservableQueryConnection({
|
|
63
|
+
route: this.route,
|
|
64
|
+
queryName: this.queryName ?? this.constructor.name,
|
|
65
|
+
origin: this._origin,
|
|
66
|
+
apiBasePath: this._apiBasePath,
|
|
67
|
+
microservice: this._microservice,
|
|
68
|
+
args: args,
|
|
69
|
+
});
|
|
65
70
|
}
|
|
66
71
|
const parameterValues = ParametersHelper.ParametersHelper.collectParameterValues(this);
|
|
67
72
|
const { unusedParameters } = UrlHelpers.UrlHelpers.replaceRouteParameters(this.route, args);
|