Skip to content

Commit

Permalink
add actor-of for clojure actor
Browse files Browse the repository at this point in the history
  • Loading branch information
MarchLiu committed May 22, 2019
1 parent 83db162 commit 28d082d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ Support akka for clojure.

For Leiningen:
```
[liu.mars/akka-clojure "0.1.5"]
[liu.mars/akka-clojure "0.1.7"]
```

## What's New

- 0.1.7 add actor of functions for ClojureActor create
- 0.1.6 fixed bug in pipeline operator `?->`
- 0.1.5 config-value function create ConfigValue data even simple value
- 0.1.4 add config-value function for convert clojure code to typesafe config
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>liu.mars</groupId>
<artifactId>akka-clojure</artifactId>
<packaging>jar</packaging>
<version>0.1.6</version>
<version>0.1.7</version>
<name>akka-clojure</name>
<description>akka toolkit for clojure programmer</description>
<url>https://github.com/MarchLiu/akka-clojure</url>
Expand All @@ -14,7 +14,7 @@
</license>
</licenses>
<scm>
<tag>0359f0ce18332ccc0e3413908443e0e4e6ef633d</tag>
<tag>83db1620b78acbff95dd13ab5bf825d5e49d5ba5</tag>
</scm>
<build>
<sourceDirectory>src/main/clojure</sourceDirectory>
Expand Down Expand Up @@ -97,7 +97,7 @@
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit_2.12</artifactId>
<version>2.5.19</version>
<version>2.5.22</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject liu.mars/akka-clojure "0.1.6"
(defproject liu.mars/akka-clojure "0.1.7"
:description "akka toolkit for clojure programmer"
:url "https://github.com/MarchLiu/akka-clojure"
:license {:name "Eclipse Public License"
Expand All @@ -11,6 +11,6 @@
[liu.mars/jaskell "0.2.2"]]
:deploy-repositories [["releases" :clojars]
["snapshots" :clojars]]
:profiles {:test {:dependencies [[com.typesafe.akka/akka-testkit_2.12 "2.5.19"]]
:profiles {:test {:dependencies [[com.typesafe.akka/akka-testkit_2.12 "2.5.22"]]
:plugins [[lein-test-report-junit-xml "0.2.0"]]
:test-report-junit-xml {:output-dir "target/surefire-reports"}}})
13 changes: 11 additions & 2 deletions src/main/clojure/liu/mars/actor.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
(ns liu.mars.actor
(:import (akka.pattern Patterns)
(java.time Duration)
(akka.actor ActorRef AbstractActor)
(akka.actor ActorRef AbstractActor ActorSystem)
(com.typesafe.config ConfigValueFactory)
(akka.dispatch Dispatcher)))
(akka.dispatch Dispatcher)
(clojure.lang MultiFn IFn Agent)
(liu.mars ClojureActor)))

(defn ?
([actor message ^Duration timeout]
Expand Down Expand Up @@ -37,6 +39,13 @@
([actor message]
(.tell actor message (ActorRef/noSender))))

(defn actor-of
([^ActorSystem system ^MultiFn receiver ^String name]
(.actorOf system (ClojureActor/props receiver) name))
([^ActorSystem system ^IFn init ^MultiFn receiver ^String name]
(.actorOf system (ClojureActor/propsWithInit init receiver) name))
([^ActorSystem system ^IFn init ^Agent state ^MultiFn receiver ^String name]
(.actorOf system (ClojureActor/propsWithStateInit init state receiver) name)))

(defn new-state
[]
Expand Down

0 comments on commit 28d082d

Please sign in to comment.