Giter VIP home page Giter VIP logo

agentex's Introduction

Agentex

Elixir distributed agent implementation on top of Mnesia

Installation

In mix.exs:

def deps do
  [
    ...
    {:agentex, "~> 0.1"}
  ]
end

def application do
    [
      ...
      applications: [
        ...
        :agentex
      ]
end

Preparation

Schema

$ iex --cookie agentex -S mix run.distributed
  Erlang/OTP 19 [erts-8.3] [...]

Interactive Elixir (1.5.0-dev) - [...]
iex([email protected])1> nodes = [Node.self | Node.list]                
iex([email protected])2> Amnesia.stop
:stopped
iex([email protected])3> :rpc.multicall(nodes, Amnesia, :stop, [])
{[:stopped, :stopped, :stopped, :stopped, :stopped], []}
iex([email protected])4> Amnesia.Schema.destroy
:ok
iex([email protected])5> Amnesia.Schema.create(nodes)
:ok

Usage

Agentex.put :pi, 3.14
Agentex.get :pi
#⇒ 3.14
Agentex.put :credentials, %{user: "john", pass: "*********"}
Agentex.get :credentials
#⇒ %{user: "john", pass: "*********"}

Distributed usage

config.exs

config :agentex, :nodes, ~w|[email protected] [email protected]|a

Make sure, the Agentex application with the same config is starting on all the nodes listed. The first node would be considered “master” node. It will be used to produce schema and re-create tables on each subsequent application restart.

By default, the only database Agentex.Simple with the single table Agentex.Simple.Kv of type key ⇒ value is being created, though one might specify their own database, containing as many tables as needed.

In the latter case, to distinguish Agentex.{get,put} calls between different tables, the table module atom should be specified as the very first parameter:

Agentex.put Agentex.Db.Math, :pi, 3.14
Agentex.get Agentex.Db.Math, :pi
#⇒ 3.14

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/agentex.

agentex's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

hpate-omicron

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.