Class: KSConnect::API::Plugin::Domain

Inherits:
Object
  • Object
show all
Defined in:
lib/ksconnect/api/plugin/domain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/ksconnect/api/plugin/domain.rb', line 9

def data
  @data
end

#ip_addressObject

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

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/ksconnect/api/plugin/domain.rb', line 11

def name
  @name
end

#plugin_nameObject (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_dataObject (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_addressObject



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