Packages
snakepit
0.8.1
0.13.0
0.12.0
0.11.1
0.11.0
0.10.1
0.10.0
0.9.1
0.9.0
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.7
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.11
0.6.10
0.6.9
0.6.8
0.6.7
0.6.6
0.6.5
0.6.4
0.6.3
0.6.2
0.6.1
0.6.0
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.3.3
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.2
0.1.1
0.1.0
High-performance pooler and session manager for external language integrations. Supports Python, Node.js, Ruby, and more with gRPC streaming, session management, and production-ready process cleanup.
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/snakepit.status.ex
defmodule Mix.Tasks.Snakepit.Status do
@moduledoc """
Report the current status of Snakepit pools and worker queues.
"""
use Mix.Task
@shortdoc "Show Snakepit pool status"
@impl true
def run(_args) do
ensure_started!()
pooling_enabled = Application.get_env(:snakepit, :pooling_enabled, false)
if pooling_enabled do
report_pool_status()
else
Mix.shell().info("Snakepit pooling is disabled (set :pooling_enabled to true).")
end
end
defp ensure_started! do
case Application.ensure_all_started(:snakepit) do
{:ok, _apps} -> :ok
{:error, {app, reason}} -> Mix.raise("Failed to start #{app}: #{inspect(reason)}")
end
end
defp report_pool_status do
Mix.shell().info("Snakepit pool status")
Mix.shell().info(String.duplicate("-", 32))
case Snakepit.Config.get_pool_configs() do
{:ok, pools} ->
Enum.each(pools, &print_pool_status/1)
{:error, reason} ->
Mix.raise("Unable to load pool configuration: #{inspect(reason)}")
end
end
defp print_pool_status(%{name: pool_name} = pool_config) do
workers =
case Snakepit.Pool.list_workers(Snakepit.Pool, pool_name) do
{:error, :pool_not_found} -> []
list -> list
end
stats =
case Snakepit.Pool.get_stats(Snakepit.Pool, pool_name) do
{:error, :pool_not_found} -> %{}
map -> map
end
profile = Map.get(pool_config, :worker_profile, :process)
Mix.shell().info("")
Mix.shell().info("Pool: #{pool_name} (#{profile})")
Mix.shell().info(" Workers: #{length(workers)}")
Mix.shell().info(" Queued: #{Map.get(stats, :queued, 0)}")
Mix.shell().info(" Requests: #{Map.get(stats, :requests, 0)}")
Mix.shell().info(" Errors: #{Map.get(stats, :errors, 0)}")
Mix.shell().info(" Queue timeouts: #{Map.get(stats, :queue_timeouts, 0)}")
end
end