Class: ConfigRuntimeFactory
- Inherits:
-
AbstractConfigRuntimeFactory
- Object
- AbstractConfigRuntimeFactory
- ConfigRuntimeFactory
- Defined in:
- lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb
Overview
The ConfigRuntimeFactory class implements the AbstractConfigRuntimeFactory interface and provides methods for creating runtime contexts. Each method corresponds to a specific runtime (CLR, JVM, .NET Core, Perl, Ruby, Node.js, Python) and returns a RuntimeContext instance for that runtime. # @see Refer to this article on Hypertube Guides
Instance Method Summary collapse
-
#clr(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with CLR runtime.
- #get_runtime_context(runtime, config_name) ⇒ Object
-
#initialize(path) ⇒ ConfigRuntimeFactory
constructor
A new instance of ConfigRuntimeFactory.
-
#jvm(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with JVM runtime.
- #load_modules(runtime, config_name, jfr, rtm_ctx) ⇒ Object
-
#netcore(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with .NET runtime.
-
#nodejs(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Node.js runtime.
-
#perl(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Perl runtime.
-
#php(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with PHP runtime.
-
#python(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Python runtime.
-
#python27(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Python 2.7 runtime.
-
#ruby(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Ruby runtime.
Constructor Details
#initialize(path) ⇒ ConfigRuntimeFactory
Returns a new instance of ConfigRuntimeFactory.
13 14 15 16 |
# File 'lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb', line 13 def initialize(path) @path = path Transmitter.set_config_source(path) end |
Instance Method Details
#clr(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with CLR runtime.
22 23 24 |
# File 'lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb', line 22 def clr(config_name = 'default') get_runtime_context(RuntimeNameHt::CLR, config_name) end |
#get_runtime_context(runtime, config_name) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb', line 90 def get_runtime_context(runtime, config_name) jfr = JsonFileResolver.new(@path) begin license_key = jfr.get_license_key Transmitter.activate_with_credentials(license_key) rescue StandardError # licenseKey not found - do nothing end conn_type = jfr.get_channel_type(RuntimeNameHandler.get_name(runtime), config_name) conn_type = conn_type.to_s.downcase if conn_type == 'tcp' conn_data = TcpConnectionData.new(jfr.get_channel_host(RuntimeNameHandler.get_name(runtime), config_name), jfr.get_channel_port(RuntimeNameHandler.get_name(runtime), config_name)) rtm_ctx = RuntimeContext.get_instance(runtime, ConnectionType::TCP, conn_data) elsif conn_type == 'websocket' || conn_type == 'ws' conn_data = WsConnectionData.new(jfr.get_channel_host(RuntimeNameHandler.get_name(runtime), config_name)) rtm_ctx = RuntimeContext.get_instance(runtime, ConnectionType::WEB_SOCKET, conn_data) elsif conn_type == 'http2' || conn_type == 'h2' conn_data = Http2ConnectionData.new(jfr.get_channel_host(RuntimeNameHandler.get_name(runtime), config_name)) rtm_ctx = RuntimeContext.get_instance(runtime, ConnectionType::HTTP2, conn_data) elsif conn_type == 'inmemory' || conn_type == 'memory' rtm_ctx = RuntimeContext.get_instance(runtime, ConnectionType::IN_MEMORY, nil) else raise 'Invalid connection type' end load_modules(runtime, config_name, jfr, rtm_ctx) rtm_ctx end |
#jvm(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with JVM runtime.
30 31 32 |
# File 'lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb', line 30 def jvm(config_name = 'default') get_runtime_context(RuntimeNameHt::JVM, config_name) end |
#load_modules(runtime, config_name, jfr, rtm_ctx) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb', line 121 def load_modules(runtime, config_name, jfr, rtm_ctx) modules = jfr.get_modules(RuntimeNameHandler.get_name(runtime), config_name) .split(',') .reject(&:empty?) config_directory_absolute_path = File.dirname(@path) modules.each do |mod| if Pathname.new(mod).absolute? rtm_ctx.load_library(mod) else rtm_ctx.load_library(File.join(config_directory_absolute_path, mod)) end end end |
#netcore(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with .NET runtime.
38 39 40 |
# File 'lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb', line 38 def netcore(config_name = 'default') get_runtime_context(RuntimeNameHt::NETCORE, config_name) end |
#nodejs(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Node.js runtime.
62 63 64 |
# File 'lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb', line 62 def nodejs(config_name = 'default') get_runtime_context(RuntimeNameHt::NODEJS, config_name) end |
#perl(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Perl runtime.
46 47 48 |
# File 'lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb', line 46 def perl(config_name = 'default') get_runtime_context(RuntimeNameHt::PERL, config_name) end |
#php(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with PHP runtime.
78 79 80 |
# File 'lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb', line 78 def php(config_name = 'default') get_runtime_context(RuntimeNameHt::PHP, config_name) end |
#python(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Python runtime.
70 71 72 |
# File 'lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb', line 70 def python(config_name = 'default') get_runtime_context(RuntimeNameHt::PYTHON, config_name) end |
#python27(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Python 2.7 runtime.
86 87 88 |
# File 'lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb', line 86 def python27(config_name = 'default') get_runtime_context(RuntimeNameHt::PYTHON27, config_name) end |
#ruby(config_name = 'default') ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Ruby runtime.
54 55 56 |
# File 'lib/hypertube-ruby-sdk/sdk/config_runtime_factory.rb', line 54 def ruby(config_name = 'default') get_runtime_context(RuntimeNameHt::RUBY, config_name) end |