Object.NetworkProxy (object v0.1.2)

Network proxy for transparent remote Object access.

Provides a local proxy that forwards method calls to remote Objects over the network. Handles connection management, caching, retries, and circuit breaking automatically.

Features

  • Transparent proxy objects that behave like local objects
  • Method call forwarding over network
  • Response caching with TTL
  • Automatic retry with exponential backoff
  • Circuit breaker pattern for fault tolerance
  • Latency-aware routing
  • Connection pooling

Summary

Functions

Calls a method on the remote object.

Casts a message to the remote object (fire-and-forget).

Returns a specification to start this module under a supervisor.

Clears the method cache.

Creates a proxy for a remote object.

Gets statistics about the proxy.

Refreshes the remote node location.

Types

cached_result()

@type cached_result() :: %{
  result: term(),
  timestamp: DateTime.t(),
  ttl: non_neg_integer()
}

circuit_breaker_state()

@type circuit_breaker_state() :: %{
  state: :closed | :open | :half_open,
  failure_count: non_neg_integer(),
  last_failure: DateTime.t() | nil,
  success_count: non_neg_integer()
}

node_info()

@type node_info() :: %{
  id: binary(),
  address: String.t(),
  port: non_neg_integer(),
  connection_id: String.t() | nil
}

pending_call()

@type pending_call() :: %{
  from: GenServer.from(),
  method: String.t(),
  args: list(),
  attempt: non_neg_integer(),
  start_time: DateTime.t()
}

proxy_config()

@type proxy_config() :: %{
  timeout: timeout(),
  max_retries: non_neg_integer(),
  cache_ttl: non_neg_integer(),
  prefetch: boolean()
}

proxy_state()

@type proxy_state() :: %{
  object_id: String.t(),
  remote_node: node_info() | nil,
  cache: %{required(String.t()) => cached_result()},
  pending_calls: %{required(reference()) => pending_call()},
  circuit_breaker: circuit_breaker_state(),
  stats: proxy_stats(),
  config: proxy_config()
}

proxy_stats()

@type proxy_stats() :: %{
  total_calls: non_neg_integer(),
  successful_calls: non_neg_integer(),
  failed_calls: non_neg_integer(),
  cache_hits: non_neg_integer(),
  avg_latency_ms: float()
}

Functions

call(proxy, method, args \\ [], timeout \\ 5000)

@spec call(pid(), String.t(), list(), timeout()) :: term()

Calls a method on the remote object.

cast(proxy, method, args \\ [])

@spec cast(pid(), String.t(), list()) :: :ok

Casts a message to the remote object (fire-and-forget).

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear_cache(proxy)

@spec clear_cache(pid()) :: :ok

Clears the method cache.

create(object_id, opts \\ [])

@spec create(String.t(), Keyword.t()) :: {:ok, pid()} | {:error, term()}

Creates a proxy for a remote object.

get_stats(proxy)

@spec get_stats(pid()) :: proxy_stats()

Gets statistics about the proxy.

refresh_location(proxy)

@spec refresh_location(pid()) :: :ok | {:error, term()}

Refreshes the remote node location.