Giter VIP home page Giter VIP logo

ainterface's Introduction

Ainterface

Build Status

Ainterface provides APIs to communicate with Erlang processes, like Jinterface. And APIs of Ainterface are designed to integrate Akka with Erlang seamlessly.

Notice

Since Ainterface is an experimental project, there is no guarantee that APIs will not be changed.

TODO

  • Published(non hidden) mode support
  • Short node names support
  • Non distributed mode support
  • Provides binary pattern matching for ByteString

Usage

Dependency

You should add the following dependency.

libraryDependencies += "com.okumin" %% "ainterface" % "0.1"

Configuration

In application.conf,

akka {
  ainterface {
    # The name of root actor of ainterface-system.
    root-name = "ainterface-system"

    init {
      # -name
      # Makes the Erlang runtime system into a distributed node and configure the name.
      name = "node-name-your-application"

      # -setcookie
      # Sets the magic cookie of the node to Cookie.
      # If `setcookie` is not specified, `$HOME/.erlang.cookie` is used.
      #setcookie = ""
    }
  }
}

Example

First, start an Erlang node and EPMD.

$ erl -name mofu
Erlang/OTP 17 [erts-6.2.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V6.2.1  (abort with ^G)
([email protected])1>

Set up Ainterface.

scala> val config = com.typesafe.config.ConfigFactory.parseString("""
     | akka {
     |   loglevel = "ERROR"
     |   ainterface {
     |     root-name = "ainterface-system"
     |     init.name = "ainterface-sample" // the node name
     |   }
     | }
     | """)
config: com.typesafe.config.Config = Config(SimpleConfigObject({"akka":{"ainterface":{"init":{"name":"ainterface-sample"},"root-name":"ainterface-system"},"loglevel":"ERROR"}}))

scala> val system = akka.actor.ActorSystem("sample", config)
system: akka.actor.ActorSystem = akka://sample

scala> akka.ainterface.AinterfaceSystem.init(system) // initialize

Start an echo server with the registered name echo.

scala> val echo = system.actorOf(akka.actor.Props[ainterface.EchoActor])
echo: akka.actor.ActorRef = Actor[akka://sample/user/$a#1942167954]

You can send messages from the Erlang node to Akka! The echo server returns his pid and hello message.

([email protected])1> {echo, '[email protected]'} ! {self(), hello}.
{<0.38.0>,hello}
([email protected])2> flush().
Shell got {<6209.1.0>,hello}
ok

The other examples are here.

License

Apache 2.0

ainterface's People

Contributors

okumin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

todesking xuwei-k

ainterface's Issues

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.