Class: SidekiqTamer::Mongo::ServerOperation

Inherits:
Object
  • Object
show all
Includes:
Resource::ResourceDependencies
Defined in:
lib/sidekiq_tamer/mongo/server_operation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource::ResourceDependencies

#add_job, #is_consumed_by?, #jobs

Constructor Details

#initialize(host, port, operation) ⇒ ServerOperation

Returns a new instance of ServerOperation.



25
26
27
28
29
# File 'lib/sidekiq_tamer/mongo/server_operation.rb', line 25

def initialize(host, port, operation)
  @server = Server.server_for(host, port)
  @operation = operation
  SidekiqTamer::Resource::Vault.add_resources(self)
end

Instance Attribute Details

#operationObject (readonly)

Returns the value of attribute operation.



24
25
26
# File 'lib/sidekiq_tamer/mongo/server_operation.rb', line 24

def operation
  @operation
end

#serverObject (readonly)

Returns the value of attribute server.



24
25
26
# File 'lib/sidekiq_tamer/mongo/server_operation.rb', line 24

def server
  @server
end

Class Method Details

.clear_server_operationsObject



16
17
18
# File 'lib/sidekiq_tamer/mongo/server_operation.rb', line 16

def self.clear_server_operations
  @server_operations = {}
end

.server_operation_for(host, port, operation) ⇒ Object



10
11
12
13
14
# File 'lib/sidekiq_tamer/mongo/server_operation.rb', line 10

def self.server_operation_for(host, port, operation)
  key = "#{host}:#{port}:#{operation}"
  server_operations[key] ||= ServerOperation.new(host, port, operation)
  server_operations[key]
end

.server_operationsObject



20
21
22
# File 'lib/sidekiq_tamer/mongo/server_operation.rb', line 20

def self.server_operations
  @server_operations ||= {}
end

Instance Method Details

#is_healthy?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/sidekiq_tamer/mongo/server_operation.rb', line 35

def is_healthy?
  server.is_operation_safe?(@operation)
end

#nameObject



31
32
33
# File 'lib/sidekiq_tamer/mongo/server_operation.rb', line 31

def name
  "MongoDB cluster #{operation}"
end