class SidekiqUniqueJobs::Changelog
@author Mikael Henriksson <mikael@zoolutions.se>
Class Changelogs provides access to the changelog entries
def add(message:, digest:, job_id:, script:)
-
(void)
-
Parameters:
-
script
(String
) -- the name of the script adding the entry -
job_id
(String
) -- a Sidekiq JID -
digest
(String
) -- a unique digest -
message
(String
) -- a descriptive message about the entry
def add(message:, digest:, job_id:, script:) message = dump_json(message: message, digest: digest, job_id: job_id, script: script) redis { |conn| conn.zadd(key, now_f, message) } end
def entries(pattern: "*", count: nil)
-
(Array
- an array of entries)
Parameters:
-
count
(Integer
) -- the number of matches to return -
pattern
(String
) -- the pattern to match
def entries(pattern: "*", count: nil) options = {} options[:match] = pattern if pattern options[:count] = count if count redis do |conn| conn.zscan_each(key, **options).to_a.map { |entry| load_json(entry[0]) } end end
def initialize
def initialize super(CHANGELOGS) end
def page(cursor, pattern: "*", page_size: 100)
-
(Array
- Array] the total size, next cursor and changelog entries) ] the total size, next cursor and changelog entries
Parameters:
-
page_size
(Integer
) -- 100 the number of matches to return -
pattern
(String
) -- "*" the pattern to match -
cursor
(Integer
) -- the cursor for this iteration
def page(cursor, pattern: "*", page_size: 100) redis do |conn| total_size, result = conn.multi do conn.zcard(key) conn.zscan(key, cursor, match: pattern, count: page_size) end [ total_size, result[0], # next_cursor result[1].map { |entry| load_json(entry[0]) }, # entries ] end end