Class: Jiggler::Cleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/jiggler/cleaner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Cleaner

Returns a new instance of Cleaner.



7
8
9
# File 'lib/jiggler/cleaner.rb', line 7

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/jiggler/cleaner.rb', line 5

def config
  @config
end

Instance Method Details

#prune_all(pool: config.client_redis_pool) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jiggler/cleaner.rb', line 11

def prune_all(pool: config.client_redis_pool)
  pool.acquire do |conn|
    conn.pipelined do |pipeline|
      prn_retries_set(pipeline)
      prn_scheduled_set(pipeline)
      prn_dead_set(pipeline)
      prn_failures_counter(pipeline)
      prn_processed_counter(pipeline)
    end
    prn_all_queues(conn)
    prn_all_processes(conn)
  end
end

#prune_all_processes(pool: config.client_redis_pool) ⇒ Object



37
38
39
40
41
# File 'lib/jiggler/cleaner.rb', line 37

def prune_all_processes(pool: config.client_redis_pool)
  pool.acquire do |conn|
    prn_all_processes(conn)
  end
end

#prune_all_queues(pool: config.client_redis_pool) ⇒ Object



86
87
88
89
90
# File 'lib/jiggler/cleaner.rb', line 86

def prune_all_queues(pool: config.client_redis_pool)
  pool.acquire do |conn|
    prn_all_queues(conn)
  end
end

#prune_dead_set(pool: config.client_redis_pool) ⇒ Object



68
69
70
71
72
# File 'lib/jiggler/cleaner.rb', line 68

def prune_dead_set(pool: config.client_redis_pool)
  pool.acquire do |conn|
    prn_dead_set(conn)
  end
end

#prune_failures_counter(pool: config.client_redis_pool) ⇒ Object



25
26
27
28
29
# File 'lib/jiggler/cleaner.rb', line 25

def prune_failures_counter(pool: config.client_redis_pool)
  pool.acquire do |conn|
    prn_failures_counter(conn)
  end
end

#prune_process(uuid:, pool: config.client_redis_pool) ⇒ Object

uses full process uuid, it’s not exposed in the web UI can be seen in raw Jiggler.summary



45
46
47
48
49
# File 'lib/jiggler/cleaner.rb', line 45

def prune_process(uuid:, pool: config.client_redis_pool)
  pool.acquire do |conn|
    conn.call('DEL', uuid)
  end
end

#prune_process_by_hex(hex:, pool: config.client_redis_pool) ⇒ Object

hex is exposed in the web UI should look like jiggler:svr:74426a5e67db



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/jiggler/cleaner.rb', line 53

def prune_process_by_hex(hex:, pool: config.client_redis_pool)
  pool.acquire do |conn|
    processes = conn.call('SCAN', '0', 'MATCH', "#{hex}*").last
    count = processes.count
    if count == 0
      config.logger.error("No process found for #{hex}")
      return
    elsif count > 1
      config.logger.error("Multiple processes found for #{hex}, not pruning #{processes}")
      return
    end
    conn.call('DEL', processes.first)
  end
end

#prune_processed_counter(pool: config.client_redis_pool) ⇒ Object



31
32
33
34
35
# File 'lib/jiggler/cleaner.rb', line 31

def prune_processed_counter(pool: config.client_redis_pool)
  pool.acquire do |conn|
    prn_processed_counter(conn)
  end
end

#prune_queue(name:, pool: config.client_redis_pool) ⇒ Object



92
93
94
95
96
# File 'lib/jiggler/cleaner.rb', line 92

def prune_queue(name:, pool: config.client_redis_pool)
  pool.acquire do |conn|
    conn.call('DEL', "#{config.queue_prefix}#{name}")
  end
end

#prune_retries_set(pool: config.client_redis_pool) ⇒ Object



74
75
76
77
78
# File 'lib/jiggler/cleaner.rb', line 74

def prune_retries_set(pool: config.client_redis_pool)
  pool.acquire do |conn|
    prn_retries_set(conn)
  end
end

#prune_scheduled_set(pool: config.client_redis_pool) ⇒ Object



80
81
82
83
84
# File 'lib/jiggler/cleaner.rb', line 80

def prune_scheduled_set(pool: config.client_redis_pool)
  pool.acquire do |conn|
    prn_scheduled_set(conn)
  end
end