mikka 2.0.0.pre1-java → 2.0.0.pre2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +2 -2
- data/README.mdown +27 -23
- data/lib/akka.rb +10 -3
- data/lib/mikka.rb +31 -2
- data/lib/mikka/version.rb +1 -1
- data/mikka.gemspec +2 -2
- data/spec/mikka_spec.rb +1 -2
- data/spec/spec_helper.rb +1 -1
- metadata +26 -17
- data/.rvmrc +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9ad4b1f25ac369ba5265ab34499568b988cb02d5
|
4
|
+
data.tar.gz: c9cfd00074150dcba38a3c7a90bb4c35a025548a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e8e12687341ea03077585f3a3c046d3f519bb111a8459995954b812b02d7961b9f4ab824a6b12404a44aa99248f4d61a7e3f09c5abf8569aa42722e0e22926df
|
7
|
+
data.tar.gz: d3148085eb2e10fe73a84b77b4b1012ee88d49b0e75fffd64976848d0afbcf340762634bf88132f3500cd50f821e66bb7973531a400e226fa796ade89b47626d
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.mdown
CHANGED
@@ -6,31 +6,35 @@ Mikka is a thin Ruby wrapper around Akka. It makes Akka's Java API more pleasing
|
|
6
6
|
|
7
7
|
Here's a quick example:
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
9
|
+
```ruby
|
10
|
+
# first you need an ActorSystem, it contains configuration and coordinates actors
|
11
|
+
actor_system = Mikka.create_actor_system('systam')
|
12
|
+
|
13
|
+
# actors are created by the ActorSystem from an instance of Props, which is
|
14
|
+
# a container for actor configuration properties -- here we assume there
|
15
|
+
# exists a class called SomeActor
|
16
|
+
actor = actor_system.actor_of(Mikka::Props[SomeActor], 'Sigourney Weaver')
|
17
|
+
|
18
|
+
# send a message to an actor using the shovel operator, which is an alias for #tell
|
19
|
+
actor << :hello
|
20
|
+
|
21
|
+
# when you're done you can shut down your actor system, and wait for it to
|
22
|
+
# complete the shutdown process -- don't do this too early, this won't wait
|
23
|
+
# for your actors to complete processing of their mailboxes, it will just
|
24
|
+
# tell them to stop
|
25
|
+
actor_system.shutdown
|
26
|
+
actor_system.await_termination
|
27
|
+
```
|
26
28
|
|
27
29
|
that's how you create and communicate with an actor, here's how you create an actor class:
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
```ruby
|
32
|
+
class SomeActor < Mikka::Actor
|
33
|
+
def receive(message)
|
34
|
+
# do the thing
|
35
|
+
end
|
36
|
+
end
|
37
|
+
```
|
34
38
|
|
35
39
|
that's the basics. v2.0 of Mikka is a work in progress, and there will hopefully be more examples in the future. Mikka is a thin wrapper and you should be able to do everything with it that you can with Akka's Java API. It's not always pretty in Ruby, but it kind of works. Mikka's job is to make it pretty.
|
36
40
|
|
@@ -57,4 +61,4 @@ Mikka is licensed under the Apache 2 license, the same as Akka. See http://doc.a
|
|
57
61
|
|
58
62
|
## Mikka?
|
59
63
|
|
60
|
-
Mikka is a glacier close to the Akka massive.
|
64
|
+
Mikka is a glacier close to the Akka massive.
|
data/lib/akka.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'java'
|
4
|
+
require 'typesafe-config-jars'
|
4
5
|
require 'akka-actor-jars'
|
5
6
|
|
6
|
-
|
7
7
|
module Akka
|
8
8
|
module Actor
|
9
9
|
java_import 'akka.actor.ActorSystem'
|
@@ -11,14 +11,21 @@ module Akka
|
|
11
11
|
java_import 'akka.actor.UntypedActor'
|
12
12
|
java_import 'akka.actor.Props'
|
13
13
|
java_import 'akka.actor.Terminated'
|
14
|
+
java_import 'akka.actor.AllForOneStrategy'
|
15
|
+
java_import 'akka.actor.OneForOneStrategy'
|
16
|
+
java_import 'akka.actor.SupervisorStrategy'
|
17
|
+
end
|
18
|
+
|
19
|
+
module Japi
|
20
|
+
java_import 'akka.japi.Function'
|
14
21
|
end
|
15
22
|
|
16
23
|
module Dispatch
|
17
|
-
java_import '
|
24
|
+
java_import 'scala.concurrent.Await'
|
18
25
|
end
|
19
26
|
|
20
27
|
module Util
|
21
|
-
java_import '
|
28
|
+
java_import 'scala.concurrent.duration.Duration'
|
22
29
|
java_import 'akka.util.Timeout'
|
23
30
|
end
|
24
31
|
end
|
data/lib/mikka.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'akka'
|
4
|
-
|
3
|
+
require 'lib/akka'
|
5
4
|
|
6
5
|
module Mikka
|
7
6
|
def self.create_actor_system(*args)
|
@@ -68,6 +67,7 @@ module Mikka
|
|
68
67
|
def post_restart(reason); end
|
69
68
|
|
70
69
|
def onReceive(message); receive(message); end
|
70
|
+
def supervisorStrategy; supervisor_strategy; end
|
71
71
|
def preStart; super; pre_start; end
|
72
72
|
def postStop; super; post_stop; end
|
73
73
|
def preRestart(reason, message_option)
|
@@ -121,5 +121,34 @@ module Mikka
|
|
121
121
|
|
122
122
|
Props = ::Mikka::Props
|
123
123
|
end
|
124
|
+
|
125
|
+
module SupervisionDecider
|
126
|
+
class DeciderAdapter
|
127
|
+
include Akka::Japi::Function
|
128
|
+
def initialize(&block)
|
129
|
+
@apply_block = block
|
130
|
+
end
|
131
|
+
def apply(e)
|
132
|
+
# SupervisorStrategy defines methods :escalate, :stop, :restart, :resume
|
133
|
+
Akka::Actor::SupervisorStrategy.send(@apply_block.call(e))
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
class AllForOneStrategy < Akka::Actor::AllForOneStrategy
|
139
|
+
# Constructor expects a block taking 1 argument for exception
|
140
|
+
# and returning :escalate, :stop, :restart, or :resume
|
141
|
+
def initialize(max_number_of_retries, within_time_range, &block)
|
142
|
+
super(max_number_of_retries, within_time_range, SupervisionDecider::DeciderAdapter.new(&block))
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class OneForOneStrategy < Akka::Actor::OneForOneStrategy
|
147
|
+
# Constructor expects a block taking 1 argument for exception
|
148
|
+
# and returning :escalate, :stop, :restart, or :resume
|
149
|
+
def initialize(max_number_of_retries, within_time_range, &block)
|
150
|
+
super(max_number_of_retries, within_time_range, SupervisionDecider::DeciderAdapter.new(&block))
|
151
|
+
end
|
152
|
+
end
|
124
153
|
end
|
125
154
|
|
data/lib/mikka/version.rb
CHANGED
data/mikka.gemspec
CHANGED
@@ -4,7 +4,6 @@ $: << File.expand_path('../lib', __FILE__)
|
|
4
4
|
|
5
5
|
require 'mikka/version'
|
6
6
|
|
7
|
-
|
8
7
|
Gem::Specification.new do |s|
|
9
8
|
s.name = 'mikka'
|
10
9
|
s.version = Mikka::VERSION
|
@@ -17,7 +16,8 @@ Gem::Specification.new do |s|
|
|
17
16
|
|
18
17
|
s.rubyforge_project = 'mikka'
|
19
18
|
|
20
|
-
s.add_dependency '
|
19
|
+
s.add_dependency 'typesafe-config-jars', '~> 1.0.2'
|
20
|
+
s.add_dependency 'akka-actor-jars', '~> 2.2.1'
|
21
21
|
|
22
22
|
s.files = `git ls-files`.split("\n")
|
23
23
|
s.require_paths = %w(lib)
|
data/spec/mikka_spec.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
|
3
|
-
|
4
3
|
module Mikka
|
5
4
|
class TestActor < Mikka::Actor
|
6
5
|
def receive(msg)
|
@@ -59,7 +58,7 @@ module Mikka
|
|
59
58
|
end
|
60
59
|
|
61
60
|
describe '#ask' do
|
62
|
-
it 'sends a message'
|
61
|
+
it 'sends a message' do
|
63
62
|
# future = actor.ask(:hi, 1000)
|
64
63
|
# reply = Mikka.await_result(future, :timeout => '1000ms')
|
65
64
|
# reply.should == :hi
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mikka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 2.0.0.pre1
|
4
|
+
version: 2.0.0.pre2
|
6
5
|
platform: java
|
7
6
|
authors:
|
8
7
|
- Theo Hultberg
|
@@ -10,22 +9,34 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2013-10-11 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: typesafe-config-jars
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 1.0.2
|
21
|
+
requirement: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ~>
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 1.0.2
|
26
|
+
prerelease: false
|
27
|
+
type: :runtime
|
15
28
|
- !ruby/object:Gem::Dependency
|
16
29
|
name: akka-actor-jars
|
17
30
|
version_requirements: !ruby/object:Gem::Requirement
|
18
31
|
requirements:
|
19
32
|
- - ~>
|
20
33
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
22
|
-
none: false
|
34
|
+
version: 2.2.1
|
23
35
|
requirement: !ruby/object:Gem::Requirement
|
24
36
|
requirements:
|
25
37
|
- - ~>
|
26
38
|
- !ruby/object:Gem::Version
|
27
|
-
version: 2.
|
28
|
-
none: false
|
39
|
+
version: 2.2.1
|
29
40
|
prerelease: false
|
30
41
|
type: :runtime
|
31
42
|
description: Mikka adapts Akka's Java API to fit better with Ruby
|
@@ -37,7 +48,8 @@ extensions: []
|
|
37
48
|
extra_rdoc_files: []
|
38
49
|
files:
|
39
50
|
- .gitignore
|
40
|
-
- .
|
51
|
+
- .rspec
|
52
|
+
- .travis.yml
|
41
53
|
- Gemfile
|
42
54
|
- README.mdown
|
43
55
|
- Rakefile
|
@@ -49,28 +61,25 @@ files:
|
|
49
61
|
- spec/spec_helper.rb
|
50
62
|
homepage: http://github.com/iconara/mikka
|
51
63
|
licenses: []
|
64
|
+
metadata: {}
|
52
65
|
post_install_message:
|
53
66
|
rdoc_options: []
|
54
67
|
require_paths:
|
55
68
|
- lib
|
56
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
70
|
requirements:
|
58
|
-
- -
|
71
|
+
- - '>='
|
59
72
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
61
|
-
MA==
|
62
|
-
none: false
|
73
|
+
version: '0'
|
63
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
75
|
requirements:
|
65
|
-
- -
|
66
|
-
Pg==
|
76
|
+
- - '>'
|
67
77
|
- !ruby/object:Gem::Version
|
68
78
|
version: 1.3.1
|
69
|
-
none: false
|
70
79
|
requirements: []
|
71
80
|
rubyforge_project: mikka
|
72
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 2.1.5
|
73
82
|
signing_key:
|
74
|
-
specification_version:
|
83
|
+
specification_version: 4
|
75
84
|
summary: Mikka is a JRuby wrapper for Akka
|
76
85
|
test_files: []
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm --create use jruby-1.7.0.preview2@mikka
|