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.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/javonet-ruby-sdk/sdk/javonet.rb', line 51

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.



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

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.

See Also:

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


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

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.



68
69
70
71
72
73
74
75
# File 'lib/javonet-ruby-sdk/sdk/javonet.rb', line 68

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.



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

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.

See Also:

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


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

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

.with_config(path) ⇒ ConfigRuntimeFactory

Initializes Javonet with a custom configuration file.

See Also:

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


37
38
39
40
41
42
43
44
45
# File 'lib/javonet-ruby-sdk/sdk/javonet.rb', line 37

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