miniakka 0.0.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cd368056b8b69b98c04fa5ca288575917e72fc15
4
+ data.tar.gz: d2b93794dbe8dbefcec5acb8a68bd2fbd75437cd
5
+ SHA512:
6
+ metadata.gz: 519521145df282717fefb18866a242fa1421da99641d87353ae8f065b53ee1f8cb11b69f26b9ecad5b4ae7adc9c215cc66c673be66f36eb30a5737e00cb237ff
7
+ data.tar.gz: 0274a8f50b95ba1e0fd6494b645dfe2bd8b2359fab1a44f6c575cc72c7c6b129115f410460b110e052b4d4e5d890c5c03127e663f9125be6399533778a84fa76
Binary file
Binary file
Binary file
data/lib/mini_akka.rb ADDED
@@ -0,0 +1,48 @@
1
+ require 'java'
2
+
3
+ require File.expand_path('jar/scala-library-2.11.8.jar', __dir__)
4
+ require File.expand_path('jar/config-1.3.0.jar', __dir__)
5
+ require File.expand_path('jar/akka-actor_2.11-2.4.14.jar', __dir__)
6
+
7
+ module MiniAkka
8
+ java_import 'akka.actor.UntypedActor'
9
+ java_import 'akka.actor.ActorRef'
10
+ java_import 'akka.actor.ActorSystem'
11
+ java_import 'akka.routing.RoundRobinPool'
12
+ java_import 'akka.routing.SmallestMailboxPool'
13
+ java_import 'akka.actor.Props'
14
+
15
+ DEFAULT_NR_OF_ACTORS = 20
16
+ Msg = Struct.new(:body)
17
+
18
+ module_function
19
+
20
+ def default_system_name=(value)
21
+ @default_system_name = value
22
+ end
23
+
24
+ def default_system_name
25
+ defined?(@default_system_name) ? @default_system_name : "DefaultSystem"
26
+ end
27
+
28
+ def system
29
+ @system ||= ActorSystem.create(default_system_name)
30
+ end
31
+
32
+ def system_shutdown
33
+ system.shutdown
34
+ end
35
+
36
+ def underscore_name(klass)
37
+ name = klass.to_s
38
+ name[0].downcase + name[1..-1].gsub(/[A-Z]/) { |letter| '_'+letter.downcase }
39
+ end
40
+ end
41
+
42
+ require File.expand_path('mini_akka/creator', __dir__)
43
+ require File.expand_path('mini_akka/akka_aliases', __dir__)
44
+ require File.expand_path('mini_akka/actors/actor_with_balancer', __dir__)
45
+ require File.expand_path('mini_akka/actors/simple_actor', __dir__)
46
+ require File.expand_path('mini_akka/actors/round_robin_actor', __dir__)
47
+ require File.expand_path('mini_akka/actors/smallest_mb_actor', __dir__)
48
+ require File.expand_path('mini_akka/actors/master_actor', __dir__)
@@ -0,0 +1,13 @@
1
+ module MiniAkka
2
+ class ActorWithBalancer < UntypedActor
3
+ include AkkaAliases
4
+
5
+ class << self
6
+ attr_writer :nr_of_actors
7
+
8
+ def nr_of_actors
9
+ defined?(@nr_of_actors) ? @nr_of_actors : DEFAULT_NR_OF_ACTORS
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ module MiniAkka
2
+ class MasterActor < SimpleActor
3
+ attr_reader :actor_router
4
+
5
+ def initialize(actor_class)
6
+ super()
7
+ @actor_router = self.get_context.actor_of(actor_class.props, MiniAkka.underscore_name(actor_class))
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module MiniAkka
2
+ class RoundRobinActor < ActorWithBalancer
3
+ def self.props(*params)
4
+ RoundRobinPool.new(nr_of_actors).props(
5
+ Props.create(java_class, Creator.new(self, *params)))
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ module MiniAkka
2
+ class SimpleActor < UntypedActor
3
+ include AkkaAliases
4
+
5
+ def self.props(*params)
6
+ Props.create(java_class, Creator.new(self, *params))
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ module MiniAkka
2
+ class SmallestMailboxActor < ActorWithBalancer
3
+ def self.props(*params)
4
+ SmallestMailboxPool.new(nr_of_actors).props(
5
+ Props.create(java_class, Creator.new(self, *params)))
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ module MiniAkka
2
+ module AkkaAliases
3
+ def onReceive(msg)
4
+ on_receive(msg)
5
+ end
6
+
7
+ def get_sender
8
+ getSender()
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module MiniAkka
2
+ class Creator
3
+ include Java::akka.japi.Creator
4
+
5
+ def initialize(klass, *params)
6
+ @klass = klass
7
+ @params = params
8
+ end
9
+
10
+ def create
11
+ @klass.new(*@params)
12
+ end
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: miniakka
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: java
6
+ authors:
7
+ - Adrian Haczyk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Allows create actor routers with supervisor.
14
+ email: haczyslaw@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/jar/akka-actor_2.11-2.4.14.jar
20
+ - lib/jar/config-1.3.0.jar
21
+ - lib/jar/scala-library-2.11.8.jar
22
+ - lib/mini_akka.rb
23
+ - lib/mini_akka/actors/actor_with_balancer.rb
24
+ - lib/mini_akka/actors/master_actor.rb
25
+ - lib/mini_akka/actors/round_robin_actor.rb
26
+ - lib/mini_akka/actors/simple_actor.rb
27
+ - lib/mini_akka/actors/smallest_mb_actor.rb
28
+ - lib/mini_akka/akka_aliases.rb
29
+ - lib/mini_akka/creator.rb
30
+ homepage: https://github.com/haczyslaw/miniakka
31
+ licenses:
32
+ - Apache-2.0
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 2.6.6
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: Minimalistic wrapper for Akka.
54
+ test_files: []