DeribitEx.AdapterExtensions (deribit_ex v0.1.0)

View Source

Extensions to the Adapter for integration with token management.

This module contains the functions needed to modify Adapter to integrate with the token management system without directly modifying the adapter itself.

When MM0207 is fully integrated, these functions should be moved directly into the Adapter module.

Summary

Functions

Enhances process_method_specific_request to handle resubscription after authentication.

Gets all active orders from the token manager.

Handles resubscription after reconnection and authentication.

Extends Adapter.init/1 to initialize the token manager.

Registers an order with the token manager.

Unregisters a subscription from the token manager.

Updates an order in the token manager.

Extends Adapter.handle_auth_response/2 to integrate with token manager.

Extends Adapter.handle_exchange_token_response/2 to integrate with token manager.

Extends Adapter.handle_fork_token_response/2 to integrate with token manager.

Extends Adapter.handle_logout_response/2 to integrate with token manager.

Functions

enhanced_process_method_specific_request(request, message, state, original_handler)

@spec enhanced_process_method_specific_request(map(), map(), map(), function()) ::
  map()

Enhances process_method_specific_request to handle resubscription after authentication.

This function adds resubscription handling to the existing process_method_specific_request function.

get_active_orders(state)

@spec get_active_orders(map()) :: {:ok, list()} | {:error, any()}

Gets all active orders from the token manager.

Use this function to access active orders.

handle_reconnect_authenticated(state)

@spec handle_reconnect_authenticated(map()) :: {:ok, map()} | {:error, any(), map()}

Handles resubscription after reconnection and authentication.

Call this function after handling reconnection with authentication.

init_with_token_manager(state)

@spec init_with_token_manager(map()) :: map()

Extends Adapter.init/1 to initialize the token manager.

Call this function from Adapter.init/1 to add token manager to state.

register_order_with_token_manager(state, order)

@spec register_order_with_token_manager(map(), map()) :: map()

Registers an order with the token manager.

Call this function when creating a new order.

register_subscription_with_token_manager(state, channel, params, subscription_info)

@spec register_subscription_with_token_manager(map(), String.t(), map(), map()) ::
  map()

Registers a subscription with the token manager.

Call this function from Adapter.handle_subscription_response/2 after state updates.

unregister_subscription_from_token_manager(state, channel)

@spec unregister_subscription_from_token_manager(map(), String.t()) :: map()

Unregisters a subscription from the token manager.

Call this function when unsubscribing from a channel.

update_order_in_token_manager(state, order)

@spec update_order_in_token_manager(map(), map()) :: map()

Updates an order in the token manager.

Call this function when order status changes.

update_token_manager_from_auth(response, state)

@spec update_token_manager_from_auth(map(), map()) :: map()

Extends Adapter.handle_auth_response/2 to integrate with token manager.

Call this function from Adapter.handle_auth_response/2 after state updates.

update_token_manager_from_exchange(response, request, state)

@spec update_token_manager_from_exchange(map(), map(), map()) :: map()

Extends Adapter.handle_exchange_token_response/2 to integrate with token manager.

Call this function from Adapter.handle_exchange_token_response/2 after state updates.

update_token_manager_from_fork(response, request, state)

@spec update_token_manager_from_fork(map(), map(), map()) :: map()

Extends Adapter.handle_fork_token_response/2 to integrate with token manager.

Call this function from Adapter.handle_fork_token_response/2 after state updates.

update_token_manager_from_logout(state)

@spec update_token_manager_from_logout(map()) :: map()

Extends Adapter.handle_logout_response/2 to integrate with token manager.

Call this function from Adapter.handle_logout_response/2 after state updates.