View Source README

Venomous

A wrapper for managing concurrent Erlport Python processes with ease.

CI Hex.pm Hex.pm

Installation

Add :venomous to your list of dependencies in mix.exs:

def deps do
  [
    {:venomous, "~> 0.1.1"}
  ]
end

Getting Started

Check the documentation for more in-depth information.

For custom type conversion read Erlport documentation ### Configure the SnakeManager options

  config :venomous, :snake_manager, %{
    # Optional :erlport encoder/decoder for type conversion between elixir/python applied to all workers.
    erlport_encoder: %{
      module: :my_encoder_module,
      func: :encode_my_snakes_please,
      args: []
    },
    # TTL whenever python process is inactive. Default: 15
    snake_ttl_minutes: 10,
    # Number of python workers that don't get cleared by SnakeManager when their TTL while inactive ends. Default: 10
    perpetual_workers: 1,
    # Interval for killing python processes past their ttl while inactive. Default: 60_000ms (1 min)
    cleaner_interval: 5_000
  }

### Configure the SnakeSupervisor to start on application boot.

  defmodule YourApp.Application do
    @moduledoc false

    use Application

    @doc false
    def start(_type, _args) do
      children = [
        {Venomous.SnakeSupervisor, [strategy: :one_for_one, max_restarts: 0, max_children: 50]}
      ]
      opts = [strategy: :one_for_one, name: YourApp.Supervisor]
      Supervisor.start_link(children, opts)
    end
  end