Class: Rox::Server::RoxServer

Inherits:
Object
  • Object
show all
Defined in:
lib/rox/server/rox_server.rb

Class Method Summary collapse

Class Method Details

.add_custom_properties(property_factory) ⇒ Object



38
39
40
41
42
# 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) ⇒ Object



56
57
58
# File 'lib/rox/server/rox_server.rb', line 56

def context=(context)
  @core.context = context
end

.dump_stateObject



100
101
102
# File 'lib/rox/server/rox_server.rb', line 100

def dump_state
  @core.dump_state
end

.dynamic_apiObject



96
97
98
# File 'lib/rox/server/rox_server.rb', line 96

def dynamic_api
  @core.dynamic_api(Rox::Server::ServerEntitiesProvider.new)
end

.fetchObject



60
61
62
63
64
65
66
67
68
69
# File 'lib/rox/server/rox_server.rb', line 60

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) ⇒ Object



44
45
46
# File 'lib/rox/server/rox_server.rb', line 44

def register(rox_container)
  @core.register(rox_container)
end

.register_with_namespace(namespace, rox_container) ⇒ Object



48
49
50
# File 'lib/rox/server/rox_server.rb', line 48

def register_with_namespace(namespace, rox_container)
  @core.register_with_namespace(namespace, rox_container)
end

.set_custom_boolean_property(name, value = nil, &block) ⇒ Object



76
77
78
79
# File 'lib/rox/server/rox_server.rb', line 76

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) ⇒ Object



86
87
88
89
# File 'lib/rox/server/rox_server.rb', line 86

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) ⇒ Object



81
82
83
84
# File 'lib/rox/server/rox_server.rb', line 81

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) ⇒ Object



91
92
93
94
# File 'lib/rox/server/rox_server.rb', line 91

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) ⇒ Object



71
72
73
74
# File 'lib/rox/server/rox_server.rb', line 71

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) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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

.shutdownObject



31
32
33
34
35
36
# 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) ⇒ Object



52
53
54
# File 'lib/rox/server/rox_server.rb', line 52

def use_userspace_unhandled_error_handler(&handler)
  @core.userspace_unhandled_error_handler = handler
end