Module: RubySkynet
- Includes:
- SyncAttr
- Defined in:
- lib/ruby_skynet.rb,
lib/ruby_skynet.rb,
lib/ruby_skynet/client.rb,
lib/ruby_skynet/common.rb,
lib/ruby_skynet/server.rb,
lib/ruby_skynet/railtie.rb,
lib/ruby_skynet/service.rb,
lib/ruby_skynet/version.rb,
lib/ruby_skynet/zookeeper.rb,
lib/ruby_skynet/connection.rb,
lib/ruby_skynet/exceptions.rb,
lib/ruby_skynet/ruby_skynet.rb,
lib/ruby_skynet/zookeeper/registry.rb,
lib/ruby_skynet/doozer/service_registry.rb,
lib/ruby_skynet/static_service_registry.rb,
lib/ruby_skynet/zookeeper/cached_registry.rb,
lib/ruby_skynet/zookeeper/json/serializer.rb,
lib/ruby_skynet/zookeeper/service_registry.rb,
lib/ruby_skynet/zookeeper/json/deserializer.rb,
lib/rails/generators/ruby_skynet/config/config_generator.rb
Overview
RubySkynet Sevices Registry
Based on the Skynet Services Registry, obtains and keeps up to date a list of all services and which servers they are available on.
Defined Under Namespace
Modules: Common, Doozer, Generators, Service, Zookeeper Classes: Client, Connection, Exception, InvalidConfigurationException, InvalidServiceException, ProtocolError, Railtie, Server, ServiceException, ServiceUnavailable, SkynetException, StaticServiceRegistry
Constant Summary collapse
- VERSION =
"2.0.0"
- @@config =
nil
Class Method Summary collapse
-
.configure!(filename = nil, environment = nil) ⇒ Object
Load the Configuration information from a YAML file filename: Name of file to read.
-
.configured? ⇒ Boolean
Returns [Boolean] whether the RubySkynet.configure! method has already been called.
-
.local_ip_address ⇒ Object
The ip address at which this server instance can be reached by remote Skynet clients Note: Must be an IP address, not the hostname.
- .local_ip_address=(local_ip_address) ⇒ Object
-
.region ⇒ Object
Returns the default region for all Ruby Skynet Clients and Services.
-
.region=(region) ⇒ Object
Sets the default region to use for Skynet Clients and Services.
-
.registry_config ⇒ Object
Returns the current Registry Config information.
-
.server_port ⇒ Object
Returns the starting port for the server to listen on If this port is in use the next available port will be used upto 999 above the server_port value.
- .server_port=(server_port) ⇒ Object
-
.service_registry=(service_registry) ⇒ Object
Set the services registry It is recommended to call RubySkynet.configure! rather than calling this method directly.
-
.services_path ⇒ Object
Returns the service_path where services are located.
-
.services_path=(services_path) ⇒ Object
Sets the service_path where services are located.
Class Method Details
.configure!(filename = nil, environment = nil) ⇒ Object
Load the Configuration information from a YAML file
filename:
Name of file to read.
Mandatory for non-Rails apps
Default: Rails.root/config/ruby_skynet.yml
environment:
Which environment config to load. Usually: production, development, etc.
Default: Rails.env
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/ruby_skynet/ruby_skynet.rb', line 81 def self.configure!(filename=nil, environment=nil) config_file = filename.nil? ? Rails.root.join('config', 'ruby_skynet.yml') : Pathname.new(filename) raise "ruby_skynet config not found. Create a config file at: config/ruby_skynet.yml" unless config_file.file? config = YAML.load(ERB.new(File.new(config_file).read).result)[environment || Rails.env] raise("Environment #{Rails.env} not defined in config/ruby_skynet.yml") unless config @@config = config.dup RubySkynet.region = config.delete(:region) || 'Development' RubySkynet.services_path = config.delete(:services_path) || 'app/services' RubySkynet.server_port = config.delete(:server_port) || 2000 RubySkynet.local_ip_address = config.delete(:local_ip_address) || Common::local_ip_address # Extract the registry configuration element RubySkynet.service_registry = ServiceRegistry.new( :registry => config.delete(:registry) ) config.each_pair {|k,v| warn "Ignoring unknown RubySkynet config option #{k} => #{v}"} end |
.configured? ⇒ Boolean
Returns [Boolean] whether the RubySkynet.configure! method has already been called
104 105 106 |
# File 'lib/ruby_skynet/ruby_skynet.rb', line 104 def self.configured? !@@config.nil? end |
.local_ip_address ⇒ Object
The ip address at which this server instance can be reached by remote Skynet clients Note: Must be an IP address, not the hostname
41 42 43 |
# File 'lib/ruby_skynet/ruby_skynet.rb', line 41 def self.local_ip_address @@local_ip_address ||= Common::local_ip_address end |
.local_ip_address=(local_ip_address) ⇒ Object
45 46 47 |
# File 'lib/ruby_skynet/ruby_skynet.rb', line 45 def self.local_ip_address=(local_ip_address) @@local_ip_address = local_ip_address end |
.region ⇒ Object
Returns the default region for all Ruby Skynet Clients and Services
8 9 10 |
# File 'lib/ruby_skynet/ruby_skynet.rb', line 8 def self.region @@region ||= 'Development' end |
.region=(region) ⇒ Object
Sets the default region to use for Skynet Clients and Services
13 14 15 |
# File 'lib/ruby_skynet/ruby_skynet.rb', line 13 def self.region=(region) @@region = region end |
.registry_config ⇒ Object
Returns the current Registry Config information
By default it connects to a local ZooKeeper instance Use .configure! to supply a configuration file with any other settings
62 63 64 |
# File 'lib/ruby_skynet/ruby_skynet.rb', line 62 def self.registry_config @@config.dup if @@config end |
.server_port ⇒ Object
Returns the starting port for the server to listen on If this port is in use the next available port will be used upto 999 above the server_port value
30 31 32 |
# File 'lib/ruby_skynet/ruby_skynet.rb', line 30 def self.server_port @@server_port ||= 2000 end |
.server_port=(server_port) ⇒ Object
34 35 36 |
# File 'lib/ruby_skynet/ruby_skynet.rb', line 34 def self.server_port=(server_port) @@server_port = server_port end |
.service_registry=(service_registry) ⇒ Object
Set the services registry
It is recommended to call RubySkynet.configure! rather than calling this
method directly
69 70 71 |
# File 'lib/ruby_skynet/ruby_skynet.rb', line 69 def self.service_registry=(service_registry) @@service_registry = service_registry end |
.services_path ⇒ Object
Returns the service_path where services are located
18 19 20 |
# File 'lib/ruby_skynet/ruby_skynet.rb', line 18 def self.services_path @@services_path ||= 'app/services' end |
.services_path=(services_path) ⇒ Object
Sets the service_path where services are located
23 24 25 |
# File 'lib/ruby_skynet/ruby_skynet.rb', line 23 def self.services_path=(services_path) @@services_path = services_path end |