Class: TuneMyGc::Syncer
- Inherits:
-
Object
- Object
- TuneMyGc::Syncer
- Defined in:
- lib/tunemygc/syncer.rb
Constant Summary collapse
- ENVIRONMENT =
[ENV['RUBY_GC_TOKEN'], RUBY_VERSION, TuneMyGc.rails_version, ENV.select {|k,v| k =~ /RUBY_GC_/ }, TuneMyGc::VERSION, GC::OPTS, GC::INTERNAL_CONSTANTS].freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #environment(snapshotter) ⇒ Object
-
#initialize(host = TuneMyGc::HOST) ⇒ Syncer
constructor
A new instance of Syncer.
- #sync(snapshotter) ⇒ Object
- #sync_required?(snapshotter) ⇒ Boolean
Constructor Details
#initialize(host = TuneMyGc::HOST) ⇒ Syncer
Returns a new instance of Syncer.
11 12 13 |
# File 'lib/tunemygc/syncer.rb', line 11 def initialize(host = TuneMyGc::HOST) @client = TuneMyGc.http_client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/tunemygc/syncer.rb', line 9 def client @client end |
Instance Method Details
#environment(snapshotter) ⇒ Object
35 36 37 |
# File 'lib/tunemygc/syncer.rb', line 35 def environment(snapshotter) ENVIRONMENT.dup.concat([snapshotter.stat_keys, TuneMyGc.spy_id, Socket.gethostname, Process.ppid, Process.pid]) end |
#sync(snapshotter) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/tunemygc/syncer.rb', line 15 def sync(snapshotter) if sync_required?(snapshotter) response = nil timeout do response = sync_with_tuner(snapshotter) end timeout do process_config_callback(response) end if response else TuneMyGc.log "Nothing to sync, discarding #{snapshotter.size} snapshots" snapshotter.clear end end |
#sync_required?(snapshotter) ⇒ Boolean
30 31 32 33 |
# File 'lib/tunemygc/syncer.rb', line 30 def sync_required?(snapshotter) return true if ENV['RUBY_GC_SYNC_ALWAYS'] snapshotter.unit_of_work end |