ExMCP.Client.Transitions (ex_mcp v0.10.0)

View Source

State transition logic and guards for the ExMCP client state machine.

This module centralizes all state transition logic, including:

  • Guards to prevent invalid transitions
  • Data transformation functions
  • Error handling and cleanup

Summary

Functions

Adds a pending request to the ready state.

Checks if the client can connect from the current state.

Checks if a request can be sent in the current state.

Completes a request with a successful response.

Marks a request as failed and replies to the caller.

Transitions from disconnected to connecting state.

Transitions to disconnected state from any state.

Transitions from connecting to handshaking state.

Transitions from handshaking to ready state.

Transitions from ready to reconnecting state.

Functions

add_request(state, from, method, params, opts)

Adds a pending request to the ready state.

can_connect?(arg1)

Checks if the client can connect from the current state.

can_send_request?(arg1)

Checks if a request can be sent in the current state.

complete_request(state, request_id, result)

Completes a request with a successful response.

fail_request(state, request_id, reason)

Marks a request as failed and replies to the caller.

to_connecting(disconnected)

Transitions from disconnected to connecting state.

to_disconnected(current_state, reason)

Transitions to disconnected state from any state.

to_handshaking(connecting, transport_info)

Transitions from connecting to handshaking state.

to_ready(handshaking, server_info)

Transitions from handshaking to ready state.

to_reconnecting(ready, reason)

Transitions from ready to reconnecting state.