Class: Rookout::Interface
- Inherits:
-
Object
- Object
- Rookout::Interface
- Includes:
- Exceptions, Singleton
- Defined in:
- lib/rookout/interface.rb
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize ⇒ Interface
constructor
A new instance of Interface.
- #print_debug_messages ⇒ Object
- #start(options = {}) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ Interface
Returns a new instance of Interface.
11 12 13 14 |
# File 'lib/rookout/interface.rb', line 11 def initialize @rook = nil @start_options = nil end |
Instance Method Details
#flush ⇒ Object
55 56 57 |
# File 'lib/rookout/interface.rb', line 55 def flush @rook.flush unless @rook.nil? end |
#print_debug_messages ⇒ Object
16 17 18 19 |
# File 'lib/rookout/interface.rb', line 16 def puts "[Rookout] Running in debug mode" puts "[Rookout] Rookout SDK for ruby: #{Config.rookout_version}" end |
#start(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rookout/interface.rb', line 21 def start = {} return unless @rook.nil? throw_errors = [:throw_errors] == true Config.debug = evaluate_flag [:debug], "ROOKOUT_DEBUG" if Config.debug begin verify_env require_relative "rookout_singleton" configure rook = RookoutSingleton.instance @start_options[throw_errors: throw_errors] rook.connect(**@start_options) rescue LoadError raise if throw_errors $stderr.puts "[Rookout] Failed to load Rookout. Please make sure to force build native extensions by setting" \ "'bundle config force_ruby_platform true'" rescue RookMissingToken, RookInvalidToken, RookInvalidOptions, RookVersionNotSupported, RookBadProtobuf, RookWebSocketError => e raise if throw_errors $stderr.puts "[Rookout] Failed to start Rookout: #{e.}" rescue RookCommunicationException => e raise if throw_errors Logger.instance.warning "[Rookout] #{e.}" rescue Exception => e $stderr.puts e. if Config.debug raise if throw_errors end end |
#stop ⇒ Object
59 60 61 62 63 64 |
# File 'lib/rookout/interface.rb', line 59 def stop return if @rook.nil? @rook.stop @rook = nil end |