Class: GameMachine::Akka
- Inherits:
-
Object
- Object
- GameMachine::Akka
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/game_machine/akka.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#app_config ⇒ Object
readonly
Returns the value of attribute app_config.
-
#hashring ⇒ Object
readonly
Returns the value of attribute hashring.
Class Method Summary collapse
Instance Method Summary collapse
- #actor_system ⇒ Object
- #akka_config ⇒ Object
- #config_name ⇒ Object
- #init_cluster!(address) ⇒ Object
- #initialize! ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
7 8 9 |
# File 'lib/game_machine/akka.rb', line 7 def address @address end |
#app_config ⇒ Object (readonly)
Returns the value of attribute app_config.
7 8 9 |
# File 'lib/game_machine/akka.rb', line 7 def app_config @app_config end |
#hashring ⇒ Object (readonly)
Returns the value of attribute hashring.
7 8 9 |
# File 'lib/game_machine/akka.rb', line 7 def hashring @hashring end |
Class Method Details
Instance Method Details
#actor_system ⇒ Object
26 27 28 |
# File 'lib/game_machine/akka.rb', line 26 def actor_system @actor_system.actor_system end |
#akka_config ⇒ Object
34 35 36 37 38 |
# File 'lib/game_machine/akka.rb', line 34 def akka_config config = load_akka_config(config_name) config = set_address(config) config = set_seeds(config) end |
#config_name ⇒ Object
30 31 32 |
# File 'lib/game_machine/akka.rb', line 30 def config_name 'cluster' end |
#init_cluster!(address) ⇒ Object
21 22 23 24 |
# File 'lib/game_machine/akka.rb', line 21 def init_cluster!(address) @address = address @hashring = JavaLib::Hashring.new('servers',[address],3) end |
#initialize! ⇒ Object
15 16 17 18 19 |
# File 'lib/game_machine/akka.rb', line 15 def initialize! @app_config = AppConfig.instance @address = self.class.address @hashring = JavaLib::Hashring.new('servers',[address],3) end |
#start ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/game_machine/akka.rb', line 40 def start @actor_system = Actor::System.new(config_name,akka_config) @actor_system.create! JavaLib::GameMachineLoader.new.run(actor_system) if Application.config.seeds.size >= 1 Application.config.seeds.each do |seed| host,port = seed.split(':') GameMachine.logger.info "JOINING REMOTE #{host} #{port}" JavaLib::ActorUtil.joinCluster("akka.tcp", config_name, host, port.to_i) end else GameMachine.logger.info "JOINING SELF" JavaLib::ActorUtil.joinCluster("akka.tcp", config_name, app_config.config.akka.host, app_config.config.akka.port) end end |
#stop ⇒ Object
56 57 58 |
# File 'lib/game_machine/akka.rb', line 56 def stop @actor_system.shutdown! end |