# Doumi.Port

[![Hex Version](](
[![Hex Docs](](
[![Last Updated](](

<!-- MDOC !-->

`Doumi.Port` is a helper library that makes it easier to use Python, Ruby in Elixir powered by [Erlport](, [NimblePool](

**도우미(Doumi)** means "helper" in Korean.

## Why pool?

> Every time we run Python code through ErlPort, ErlPort starts an OS process, this is rather inefficient and expensive. To avoid this trap, we went looking for some pooling mechanism ...

## Why [NimblePool](

> You should consider using NimblePool whenever you have to manage sockets, **ports**, or NIF resources and you want the client to perform one-off operations on them. For example, NimblePool is a good solution to manage HTTP/1 connections, ports that need to communicate with long-running programs, etc.

## Usage

### Call Python function via Pool

defmodule MyApp.PythonPool do
  use Doumi.Port.Pool,
    adapter: Doumi.Port.Adapter.Python,
    pool_size: 4

defmodule MyApp.Application do

  @impl true
  def start(_type, _args) do
    children = [

    Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor)

defmodule MyApp.Native do
  def add(a, b) do
    {:ok, result} = MyApp.PythonPool.command(:operator, :add, [a, b])


### Init and Setup Python in Elixir application

# Create requirements.txt, .gitignores to ./priv/python
mix doumi.port.init --port python

# Add Python dependency
echo "pypdf2==3.0.1" >> ./priv/python/requirements.txt

# Install Python dependecies
mix doumi.port.setup --port python

You can install Python dependencies to your release with `mix doumi.port.setup`.

defmodule MyApp.MixProject do
  defp aliases do
      "release.setup": ["doumi.port.setup --port python", ...]


# release setup (ex. install Python dependencies, compile assets)
RUN mix release.setup


## Installation

The package can be installed by adding `doumi_port` to your list of dependencies in `mix.exs`:

def deps do
    {:doumi_port, "~> 0.6.0"},
    # To support Python >= 3.11, erlport should be overridden
    {:erlport, github: "nallwhy/erlport", ref: "6f5cb45", override: true}


- [x] Support use macro
- [x] Support Ruby
- [x] Support mix tasks that help setup Python in applications
- [x] Support mix tasks that help setup Ruby in applications
- [ ] Pool 이 위치를 알게하고, compile 시에 빌드를 하도록
- [ ] Documentation
- [ ] Write blog posts

<!-- MDOC !-->

## Doumi\*

All **Doumi** libraries:

- [Doumi.Phoenix.SVG]( A helper library that generates Phoenix function components from SVG files.
- [Doumi.Phoenix.Params]( A helper library that supports converting form to params and params to form
- [Doumi.URI.Query]( A helper library that encode complicated query of URI.

## Copyright and License

Copyright (c) 2023 Jinkyou Son (Json)

This work is free. You can redistribute it and/or modify it under the
terms of the MIT License. See the [](./ file for more details.