Class: KSConnect::API::Plugin::Domain
- Inherits:
-
Object
- Object
- KSConnect::API::Plugin::Domain
- Defined in:
- lib/ksconnect/api/plugin/domain.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#plugin_name ⇒ Object
readonly
Returns the value of attribute plugin_name.
-
#private_data ⇒ Object
readonly
Returns the value of attribute private_data.
Instance Method Summary collapse
- #add_issue(issue_type, data) ⇒ Object
- #clear_issue(issue_type) ⇒ Object
-
#initialize(name, ip_address, plugin_name) ⇒ Domain
constructor
A new instance of Domain.
- #notify(data) ⇒ Object
- #update_ip_address ⇒ Object
Constructor Details
#initialize(name, ip_address, plugin_name) ⇒ Domain
Returns a new instance of Domain.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ksconnect/api/plugin/domain.rb', line 14 def initialize(name, ip_address, plugin_name) @name = name @ip_address = ip_address @plugin_name = plugin_name @data = Data.new(plugin_name, name, type: :data) @private_data = Data.new(plugin_name, name, type: :private_data, auto_notify: true) Redis.current ||= Redis.new(driver: :hiredis) $redis ||= ConnectionPool.new(size: MAX_THREADS, timeout: 8) { Redis.current } end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/ksconnect/api/plugin/domain.rb', line 9 def data @data end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
8 9 10 |
# File 'lib/ksconnect/api/plugin/domain.rb', line 8 def ip_address @ip_address end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/ksconnect/api/plugin/domain.rb', line 11 def name @name end |
#plugin_name ⇒ Object (readonly)
Returns the value of attribute plugin_name.
12 13 14 |
# File 'lib/ksconnect/api/plugin/domain.rb', line 12 def plugin_name @plugin_name end |
#private_data ⇒ Object (readonly)
Returns the value of attribute private_data.
10 11 12 |
# File 'lib/ksconnect/api/plugin/domain.rb', line 10 def private_data @private_data end |
Instance Method Details
#add_issue(issue_type, data) ⇒ Object
45 46 47 48 49 |
# File 'lib/ksconnect/api/plugin/domain.rb', line 45 def add_issue(issue_type, data) $redis.with { |redis| redis.lpush("ks:issues_push", data.merge({ domain_name: @name, plugin_name: @plugin_name, issue_type: issue_type, request_type: 'add' }).to_json) } end |
#clear_issue(issue_type) ⇒ Object
51 52 53 54 55 |
# File 'lib/ksconnect/api/plugin/domain.rb', line 51 def clear_issue(issue_type) $redis.with { |redis| redis.lpush("ks:issues_push", { domain_name: @name, plugin_name: @plugin_name, issue_type: issue_type, request_type: 'remove' }.to_json) } end |
#notify(data) ⇒ Object
39 40 41 42 43 |
# File 'lib/ksconnect/api/plugin/domain.rb', line 39 def notify(data) $redis.with { |redis| redis.lpush("ks:notifications_push", data.merge({ domain_name: @name, plugin_name: @plugin_name }).to_json) } end |
#update_ip_address ⇒ Object
25 26 27 28 29 |
# File 'lib/ksconnect/api/plugin/domain.rb', line 25 def update_ip_address $redis.with { |redis| @ip_address = redis.hget(domains_key, name) } end |