class Rox::Server::RoxServer

Public Class Methods

add_custom_properties(property_factory) click to toggle source
# File lib/rox/server/rox_server.rb, line 38
def add_custom_properties(property_factory)
  property_factory.all_properties.each do |property|
    @core.add_custom_property_if_not_exists(property)
  end
end
context=(context) click to toggle source
# File lib/rox/server/rox_server.rb, line 52
def context=(context)
  @core.context = context
end
dump_state() click to toggle source
# File lib/rox/server/rox_server.rb, line 96
def dump_state
  @core.dump_state
end
dynamic_api() click to toggle source
# File lib/rox/server/rox_server.rb, line 92
def dynamic_api
  @core.dynamic_api(Rox::Server::ServerEntitiesProvider.new)
end
fetch() click to toggle source
# File lib/rox/server/rox_server.rb, line 56
def fetch
  Thread.new do
    Thread.current.report_on_exception = false if Thread.current.respond_to?(:report_on_exception)
    begin
      @core.fetch.join
    rescue StandardError => e
      Rox::Core::Logging.logger.error('Failed in Rox.fetch', e)
    end
  end
end
register(rox_container) click to toggle source
# File lib/rox/server/rox_server.rb, line 44
def register(rox_container)
  @core.register(rox_container)
end
set_custom_boolean_property(name, value = nil, &block) click to toggle source
# File lib/rox/server/rox_server.rb, line 72
def set_custom_boolean_property(name, value = nil, &block)
  @core.add_custom_property(Rox::Core::CustomProperty.new(name, Rox::Core::CustomPropertyType::BOOL, value,
                                                          &block))
end
set_custom_float_property(name, value = nil, &block) click to toggle source
# File lib/rox/server/rox_server.rb, line 82
def set_custom_float_property(name, value = nil, &block)
  @core.add_custom_property(Rox::Core::CustomProperty.new(name, Rox::Core::CustomPropertyType::FLOAT, value,
                                                          &block))
end
set_custom_int_property(name, value = nil, &block) click to toggle source
# File lib/rox/server/rox_server.rb, line 77
def set_custom_int_property(name, value = nil, &block)
  @core.add_custom_property(Rox::Core::CustomProperty.new(name, Rox::Core::CustomPropertyType::INT, value,
                                                          &block))
end
set_custom_semver_property(name, value = nil, &block) click to toggle source
# File lib/rox/server/rox_server.rb, line 87
def set_custom_semver_property(name, value = nil, &block)
  @core.add_custom_property(Rox::Core::CustomProperty.new(name, Rox::Core::CustomPropertyType::SEMVER, value,
                                                          &block))
end
set_custom_string_property(name, value = nil, &block) click to toggle source
# File lib/rox/server/rox_server.rb, line 67
def set_custom_string_property(name, value = nil, &block)
  @core.add_custom_property(Rox::Core::CustomProperty.new(name, Rox::Core::CustomPropertyType::STRING, value,
                                                          &block))
end
setup(api_key, rox_options = nil) click to toggle source
# File lib/rox/server/rox_server.rb, line 16
def setup(api_key, rox_options = nil)
  validate_api_key(api_key)

  rox_options = Rox::Server::RoxOptions.new if rox_options.nil?
  sdk_settings = Rox::Server::SdkSettings.new(api_key, rox_options.dev_mode_key)
  server_properties = Rox::Server::ServerProperties.new(sdk_settings, rox_options)

  RoxServer.add_custom_properties(Rox::Core::PropertyFactory.new(server_properties))

  @@thread = Thread.new do
    Thread.current.report_on_exception = false if Thread.current.respond_to?(:report_on_exception)
    @core.setup(sdk_settings, server_properties).join
  end
end
shutdown() click to toggle source
# File lib/rox/server/rox_server.rb, line 31
def shutdown
  return if !defined?(@@thread) || @@thread.nil?

  Thread.kill(@@thread)
  @core.shutdown
end
use_userspace_unhandled_error_handler(&handler) click to toggle source
# File lib/rox/server/rox_server.rb, line 48
def use_userspace_unhandled_error_handler(&handler)
  @core.userspace_unhandled_error_handler = handler
end

Private Class Methods

validate_api_key(api_key) click to toggle source
# File lib/rox/server/rox_server.rb, line 102
def validate_api_key(api_key)
  raise ArgumentError, 'api_key is not valid' if (api_key =~ /^[a-f\d]{24}$/).nil?

  true
end