All Projects → clojang → jiface

clojang / jiface

Licence: other
A Clojure-idiomatic wrapper around Erlang's JInterface

Programming Languages

clojure
4091 projects
HTML
75241 projects
Makefile
30231 projects

Projects that are alternatives of or similar to jiface

clojang
Clojure API for Erlang/OTP Communications (built on jiface)
Stars: ✭ 61 (+125.93%)
Mutual labels:  otp, jvm, beam, jinterface
elixir-fire-brigade-workshop
Workshop "Join the Elixir Fire Brigade - Level-up Your Elixir Debugging Skills" (ElixirConf US 2017)
Stars: ✭ 14 (-48.15%)
Mutual labels:  otp, beam
play-java-chatroom-example
Example Chatroom with Java API
Stars: ✭ 33 (+22.22%)
Mutual labels:  jvm
kronos
Management of arithmetic operations on dates
Stars: ✭ 23 (-14.81%)
Mutual labels:  otp
ootp
OOTP (Open One-time Password) is a supports multiple programming languages. The generated one-time passwords are fully compliant with HOTP (HMAC-based One-time Password) and TOTP (Time-based One-time Password). 🚀It's easy to use!
Stars: ✭ 17 (-37.04%)
Mutual labels:  otp
pigame
Just a game server template for Erlang/OTP.
Stars: ✭ 25 (-7.41%)
Mutual labels:  otp
JavaHub
Java程序员学习之路,持续更新原创内容,欢迎Star
Stars: ✭ 27 (+0%)
Mutual labels:  jvm
director
Director is a production-ready supervisor and manager for Erlang/Elixir processes that focuses on speed, performance and flexibility.
Stars: ✭ 62 (+129.63%)
Mutual labels:  otp
play-scala-tls-example
A Play application using HTTPS and WS with optional client authentication
Stars: ✭ 44 (+62.96%)
Mutual labels:  jvm
spacesuit
API Gateway with URL remapping
Stars: ✭ 19 (-29.63%)
Mutual labels:  beam
2FAuth
A Web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes
Stars: ✭ 664 (+2359.26%)
Mutual labels:  otp
java-manta
Java Manta Client SDK
Stars: ✭ 16 (-40.74%)
Mutual labels:  jvm
jacobin
A more than minimal JVM written in Go and capable of running Java 17 classes.
Stars: ✭ 59 (+118.52%)
Mutual labels:  jvm
londogard-nlp-toolkit
Londogard Natural Language Processing Toolkit written in Kotlin
Stars: ✭ 49 (+81.48%)
Mutual labels:  jvm
aot
Russian morphology for Java
Stars: ✭ 41 (+51.85%)
Mutual labels:  jvm
j2cache
java实现的缓存策略组件,支持多种缓存产品,开发人员可以像Map一样使用,简单方便。支持的存储方案:jvm\redis\ignite\hazelcast\guava
Stars: ✭ 33 (+22.22%)
Mutual labels:  jvm
Cojen
Java bytecode generation and disassembly tools
Stars: ✭ 28 (+3.7%)
Mutual labels:  jvm
one-wallet
1wallet - unconventional keyless, non-custodial wallet secured by Google Authenticator. EVM-compatible, smart contract operated, with composable security.
Stars: ✭ 85 (+214.81%)
Mutual labels:  otp
logparser
Easy parsing of Apache HTTPD and NGINX access logs with Java, Hadoop, Hive, Pig, Flink, Beam, Storm, Drill, ...
Stars: ✭ 139 (+414.81%)
Mutual labels:  beam
DPOTPView
Customisable OTP view and Passcode view
Stars: ✭ 52 (+92.59%)
Mutual labels:  otp

jiface

Build Status Dependencies Status Clojars Project

Erlang's JInterface in Idiomatic Clojure

Project logo

Contents

Introduction

This project provides a solution to the Clojure JInterface Problem. While JInterface is an invaluable tool for projects that need to have JVM and Erlang VM languages communicating with each other, it is rather verbose and cumbersome to do so in Clojure. The syntactical burden is often enough to discourage experimentation and play (essential ingredients for innovation). The primary goal of jiface is to make it easier to write Clojure programs that need to communicate with Erlang nodes (including LFE and Elixir).

For a comparison of JInterface, the low-level jiface API, and the high-level clojang API, see the APIs summary page.

Changes

For details on breaking changes made between jiface releases, see the changes page.

Dependencies

  • Java
  • Erlang (epmd in particular)
  • lein

The default (and tested) version combinations are as follows:

jiface JInterface Erlang Release Erlang Version (erts)
0.7.0 1.10 22.0 10.4
0.6.1 1.9.1 21.3 10.3
0.6.0 1.9 21.0 10
0.5.0 1.8.1 20.3 9.3
0.4.0 1.7.1 19.2, 19.3 8.2, 8.3
0.3.0 1.7.1 19.2 8.2
0.2.0 1.7.1 19.1, 19.2 8.1, 8.2
0.1.0 1.6.1 18.2, 18.3 7.2, 7.3

While other version combination may work (and existing versions may be updated to work with different onces), those are the only ones which are supported.

Versions notes:

  • The lein dep for the jiface 0.6.1 release is [clojang/jiface "0.6.1-1"]
  • The lein dep for the JInterface 1.9.1 release is [clojang/erlang-jinterface "1.9.1-3"]
  • The lein dep for the JInterface 1.10 release is [clojang/erlang-jinterface "1.10-1"]

Building

rebar3 is used for the top-level builds of the project. It runs lein under the covers in order to build the Clojure code and create the jiface.jar file. As such, to build everything -- LFE, Erlang, and Clojure -- you need only do the following:

  • rebar3 compile

If you wish to build your own JInterface .jar file and not use the one we've uploaded to Clojars, you'll need to follow the instructions given in the documentation here:

Documentation

Project documentation, including jiface API reference docs, Javadocs for JInterface, and the Erlang JInterface User's Guide, is available here:

Of particular note:

High-level API docs:

  • Clojang User's Guide - An adaptation of the jiface User's Guide for the mid-level idiomatic Clojure API

Usage

Using jiface in a project is just like any other Clojure library. Just add the following to the :dependencies in your project.clj file:

Clojars Project

For the Erlang/LFE side of things, you just need to add the Github URL to your rebar.config file, as with any other rebar-based Erlang VM project.

As for actual code usage, the documentation section provides links to developer guides and API references, but below is quick example.

Start LFE in distributed mode:

$ lfe -sname clojang-lfe
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] ...

   ..-~.~_~---..
  (      \\     )    |   A Lisp-2+ on the Erlang VM
  |`-.._/_\\_.-';    |   Type (help) for usage info.
  |         g (_ \   |
  |        n    | |  |   Docs: http://docs.lfe.io/
  (       a    / /   |   Source: http://github.com/rvirding/lfe
   \     l    (_/    |
    \   r     /      |   LFE v0.11.0-dev (abort with ^G)
     `-E___.-'

(clojang-lfe@mndltl01)>

Then start up a jiface Clojure REPL:

$ lein repl

And paste the following:

(require '[jiface.otp.messaging :as messaging]
         '[jiface.otp.nodes :as nodes]
         '[jiface.erlang.types :as types]
         '[jiface.erlang.tuple :as tuple-type])
(def node (nodes/node "gurka"))
(def mbox (messaging/mbox node))
(messaging/register-name mbox "echo")
(def msg (into-array
           (types/object)
           [(messaging/self mbox)
            (types/atom "hello, world")]))
(messaging/! mbox "echo" "gurka" (types/tuple msg))
(messaging/receive mbox)

When you paste the receive function, you'll get something like this:

#object[com.ericsson.otp.erlang.OtpErlangTuple
        0x4c9e3fa6
        "{#Pid<[email protected]>,'hello, world'}"]

In the LFE REPL, you can send a message to your new Clojure node:

(lfe@mndltl01)> (! #(echo gurka@mndltl01) `#(,(self) hej!))
#(<0.35.0> hej!)

Then back in Clojure, check the sent message and send a response:

(def data (messaging/receive mbox))
(def lfe-pid (tuple-type/get-element data 0))
(messaging/! mbox lfe-pid (types/tuple msg))

Then, back in LFE, flush the REPL's process mbox to see what has been sent to it:

(lfe@mndltl01)> (c:flush)
Shell got {<5926.1.0>,'hello, world'}
ok

Running Tests

All the tests may be run with just one command:

$ rebar3 eunit

This will not only run Erlang and LFE unit tests, it also runs the Clojure unit tests for jiface.

Clojure Test Selectors

If you would like to be more selective in the types of jiface tests which get run, you may be interested in reading this section.

The jiface tests use metadata annotations to indicate whether they are unit, system, or integration tests. to run just the unit tests, you can do any one of the following, depending upon what you're used to:

$ lein test
$ lein test :unit
$ lein test :default

To run just the system tests:

$ lein test :system

And, similarly, just the integration tests:

$ lein test :integration

To run everything:

$ lein test :all

This is what is used by the rebar3 configuration to run the jiface tests.

Erlang, Clojure, and JInterface

If you are interested in building your own JInterface .jar file for use with a Clojure project, be sure fo check out the jinterface-builder Clojang project. The project README has everything you need to get started.

Donating

A donation account for supporting development on this project has been set up on Liberapay here:

You can learn more about Liberapay on its Wikipedia entry or on the service's "About" page.

License

Copyright © 2018 The Clojang Project

Copyright © 2016-2017 Duncan McGreggor

Distributed under the Apache License Version 2.0.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].