Class: RuntimeBridge

Inherits:
Object
  • Object
show all
Defined in:
lib/hypertube-ruby-sdk/sdk/runtime_bridge.rb

Overview

The RuntimeBridge class is a singleton class that serves as the entry point for interacting with Hypertube. It provides methods to activate and initialize the RuntimeBridge SDK. It supports both in-memory and TCP connections.

See Also:

  • to this {https://www.hypertube.dev/guides/v2/ruby/foundations/javonet-static-class article on RuntimeBridge Guides}

Class Method Summary collapse

Class Method Details

.activate(license_key) ⇒ Integer

Activates RuntimeBridge with the provided license key and optionally with proxy data.

Parameters:

  • license_key (String)

    The license key to activate RuntimeBridge.

Returns:

  • (Integer)

    The activation status code.

See Also:



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/hypertube-ruby-sdk/sdk/runtime_bridge.rb', line 57

def self.activate(license_key)
  if license_key != ActivationHelper.temporary_license_key
    ActivationHelper.temporary_license_key = license_key
    SdkMessageHelper.send_message_to_app_insights('SdkMessage', 'Activation')
  end

  ActivationHelper.temporary_license_key = license_key
  Transmitter.activate(license_key)
rescue Exception => e
  SdkMessageHelper.send_message_to_app_insights('SdkException', e.message)
  raise e
end

.add_config(priority, config_source) ⇒ Object

Adds configuration from the given source with specified priority.

Parameters:

  • priority (Integer)

    ConfigPriority value.

  • config_source (String)

    Path or string with configuration data.



102
103
104
105
106
107
# File 'lib/hypertube-ruby-sdk/sdk/runtime_bridge.rb', line 102

def self.add_config(priority, config_source)
  ConfigSourceResolver.add_configs(priority, config_source)
rescue Exception => e
  SdkMessageHelper.send_message_to_app_insights('SdkException', e.message)
  raise e
end

.get_runtime_info(get_loaded_modules) ⇒ String

Gets information about the current runtime.

Parameters:

  • get_loaded_modules (Boolean)

    Whether to include loaded modules in the runtime information.

Returns:

  • (String)

    Information about the current runtime.



95
96
97
# File 'lib/hypertube-ruby-sdk/sdk/runtime_bridge.rb', line 95

def self.get_runtime_info(get_loaded_modules)
  RuntimeLogger.get_runtime_info(get_loaded_modules)
end

.in_memoryRuntimeFactory

Initializes RuntimeBridge using an in-memory channel on the same machine.

Returns:

  • (RuntimeFactory)

    A RuntimeFactory instance configured for an in-memory connection.

See Also:

  • to this {https://www.hypertube.dev/guides/v2/ruby/foundations/in-memory-channel article on RuntimeBridge Guides}


22
23
24
# File 'lib/hypertube-ruby-sdk/sdk/runtime_bridge.rb', line 22

def self.in_memory
  RuntimeFactory.new(ConnectionType::IN_MEMORY, nil)
end

.initialize_rc(config_name) ⇒ RuntimeContext

Initializes RuntimeContext for the given configuration name.

Parameters:

  • config_name (String)

    Name of the configuration.

Returns:



112
113
114
115
116
117
118
# File 'lib/hypertube-ruby-sdk/sdk/runtime_bridge.rb', line 112

def self.initialize_rc(config_name)
  config = ConfigSourceResolver.get_config(config_name)
  RuntimeContext.initialize_runtime_context(config)
rescue Exception => e
  SdkMessageHelper.send_message_to_app_insights('SdkException', e.message)
  raise e
end

.set_config_source(config_source) ⇒ Object

Sets the configuration source for the RuntimeBridge SDK.

Parameters:

  • config_source (String)

    The configuration source.



72
73
74
75
76
77
# File 'lib/hypertube-ruby-sdk/sdk/runtime_bridge.rb', line 72

def self.set_config_source(config_source)
  Transmitter.set_config_source(config_source)
rescue Exception => e
  SdkMessageHelper.send_message_to_app_insights('SdkException', e.message)
  raise e
end

.set_working_directory(path) ⇒ Object

Sets the working directory for the RuntimeBridge SDK.

Parameters:

  • path (String)

    The working directory path.



81
82
83
84
85
86
87
88
89
90
# File 'lib/hypertube-ruby-sdk/sdk/runtime_bridge.rb', line 81

def self.set_working_directory(path)
  path.gsub!('\\', '/')
  path += '/' unless path.end_with?('/')
  FileUtils.mkdir_p(path, mode: 0o700)
  ActivationHelper.working_directory = path
  Transmitter.set_working_directory(path)
rescue Exception => e
  SdkMessageHelper.send_message_to_app_insights('SdkException', e.message)
  raise e
end

.tcp(tcp_connection_data) ⇒ RuntimeFactory

Initializes RuntimeBridge with a TCP connection to a remote machine.

Parameters:

Returns:

  • (RuntimeFactory)

    A RuntimeFactory instance configured for a TCP connection.

See Also:

  • to this {https://www.hypertube.dev/guides/v2/ruby/foundations/tcp-channel article on RuntimeBridge Guides}


30
31
32
# File 'lib/hypertube-ruby-sdk/sdk/runtime_bridge.rb', line 30

def self.tcp(tcp_connection_data)
  RuntimeFactory.new(ConnectionType::TCP, tcp_connection_data)
end

.web_socket(ws_connection_data) ⇒ RuntimeFactory

Initializes RuntimeBridge with a WebSocket connection to a remote machine.

Parameters:

Returns:

  • (RuntimeFactory)

    A RuntimeFactory instance configured for a WebSocket connection.

See Also:

  • to this {https://www.hypertube.dev/guides/v2/ruby/foundations/websocket-channel article on RuntimeBridge Guides}


38
39
40
# File 'lib/hypertube-ruby-sdk/sdk/runtime_bridge.rb', line 38

def self.web_socket(ws_connection_data)
  RuntimeFactory.new(ConnectionType::WEB_SOCKET, ws_connection_data)
end

.with_config(path) ⇒ ConfigRuntimeFactory

Initializes RuntimeBridge with a custom configuration file.

Parameters:

  • path (String)

    Path to a configuration file.

Returns:

See Also:

  • to this {https://www.hypertube.dev/guides/v2/ruby/foundations/configure-channel article on RuntimeBridge Guides}


46
47
48
49
50
51
# File 'lib/hypertube-ruby-sdk/sdk/runtime_bridge.rb', line 46

def self.with_config(path)
  ConfigRuntimeFactory.new(path)
rescue Exception => e
  SdkMessageHelper.send_message_to_app_insights('SdkException', e.message)
  raise e
end