Giter Site home page Giter Site logo

std_json_io's Introduction

StdJsonIo

Starts a pool of workers that communicate with an external script via JSON over STDIN/STDOUT.

Originally written to use react-stdio but can be used with any process that reads a JSON object from STDIN and outputs JSON on STDOUT.

Installation

If available in Hex, the package can be installed as:

  1. Add std_json_io to your list of dependencies in mix.exs:

    def deps do [{:std_json_io, "~> 0.1.0"}] end

  2. Ensure std_json_io is started before your application:

    def application do [applications: [:std_json_io]] end

Setup

Define a module and use StdJsonIo.

defmodule MyApp.ReactIo do
  use StdJsonIo, otp_app: :my_app
end

When you use StdJsonIo your module becomes a supervisor. You'll need to add it to your supervision tree.

children = [
  # snip
  supervisor(MyApp.ReactIo, [])
]

opts = [strategy: :one_for_one, name: MyApp]

Supervisor.start_link(children, opts)

Configuration

You can either configure as additional arguments of the use statement, or in your config file.

config :my_app, MyApp.ReactIo,
  pool_size: 20, # default 5
  max_overflow: 10, # default 10
  script: "path/to/script", # for react-io use "react-stdio"
  watch_files: [
    Path.join([__DIR__, "../priv/server/js/component.js"]) # do not watch files in dev
  ]
  • script - the script to run for the IO server
  • watch_files - A list of files to watch for changes. When the file changes, kill the IO worker and restart, picking up any changes. Use only in dev.
  • pool_size - The size for the pool of workers - See poolboy size
  • max_overflow - The poolboy max_overflow

std_json_io's People

Contributors

asiniy avatar ribbedcrown avatar tompave avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.