WeaviateEx.Client.State (WeaviateEx v0.7.4)
View SourceClient lifecycle state tracking.
Tracks the state of a client connection including:
- Connection status
- Request and error counts
- Timestamps for lifecycle events
Example
state = State.new()
|> State.connected()
|> State.record_request()
|> State.record_request()
IO.puts("Request count: #{state.request_count}")
Summary
Functions
Transition to closed status.
Transition to connected status.
Transition to disconnected status with reason.
Create new client state.
Record an error.
Record a successful request.
Types
@type status() :: :initializing | :connected | :disconnected | :closed
@type t() :: %WeaviateEx.Client.State{ created_at: DateTime.t(), error_count: non_neg_integer(), last_error: term() | nil, last_used_at: DateTime.t() | nil, request_count: non_neg_integer(), status: status() }
Functions
Transition to closed status.
Example
state = State.connected(state) |> State.closed()
Transition to connected status.
Example
state = State.new() |> State.connected()
Transition to disconnected status with reason.
Example
state = State.connected(state) |> State.disconnected(:network_error)
@spec new() :: t()
Create new client state.
Initializes state with :initializing status and current timestamp.
Example
state = State.new()
Record an error.
Increments the error count and stores the last error.
Example
state = State.record_error(state, %RuntimeError{message: "connection timeout"})
Record a successful request.
Increments the request count and updates the last_used_at timestamp.
Example
state = State.record_request(state)