Class: Javonet

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

Overview

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

See Also:

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

Class Method Summary collapse

Class Method Details

.activate(license_key) ⇒ Integer

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

Parameters:

  • license_key (String)

    The license key to activate Javonet.

Returns:

  • (Integer)

    The activation status code.

See Also:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/javonet-ruby-sdk/sdk/javonet.rb', line 58

def self.activate(license_key)
  begin
    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
    return Transmitter.activate(license_key)
  rescue Exception => e
    SdkMessageHelper.send_message_to_app_insights("SdkException", e.message)
    raise e
  end
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.



102
103
104
# File 'lib/javonet-ruby-sdk/sdk/javonet.rb', line 102

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

.in_memoryRuntimeFactory

Initializes Javonet 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.javonet.com/guides/v2/ruby/foundations/in-memory-channel article on Javonet Guides}


20
21
22
# File 'lib/javonet-ruby-sdk/sdk/javonet.rb', line 20

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

.set_config_source(config_source) ⇒ Object

Sets the configuration source for the Javonet SDK.

Parameters:

  • config_source (String)

    The configuration source.



75
76
77
78
79
80
81
82
# File 'lib/javonet-ruby-sdk/sdk/javonet.rb', line 75

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

.set_javonet_working_directory(path) ⇒ Object

Sets the working directory for the Javonet SDK.

Parameters:

  • path (String)

    The working directory path.



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/javonet-ruby-sdk/sdk/javonet.rb', line 86

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

.tcp(tcp_connection_data) ⇒ RuntimeFactory

Initializes Javonet 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.javonet.com/guides/v2/ruby/foundations/tcp-channel article on Javonet Guides}


28
29
30
# File 'lib/javonet-ruby-sdk/sdk/javonet.rb', line 28

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

.web_socket(ws_connection_data) ⇒ RuntimeFactory

Initializes Javonet 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.javonet.com/guides/v2/ruby/foundations/websocket-channel article on Javonet Guides}


36
37
38
# File 'lib/javonet-ruby-sdk/sdk/javonet.rb', line 36

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

.with_config(path) ⇒ ConfigRuntimeFactory

Initializes Javonet with a custom configuration file.

Parameters:

  • path (String)

    Path to a configuration file.

Returns:

See Also:

  • to this {https://www.javonet.com/guides/v2/ruby/foundations/configure-channel article on Javonet Guides}


44
45
46
47
48
49
50
51
52
# File 'lib/javonet-ruby-sdk/sdk/javonet.rb', line 44

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

end