diff --git a/r2s-bwmsgsv2.rb b/r2s-bwmsgsv2.rb index bca221bc405adfd5a5ce36559d08e17c89883d3c..4122153b3af6f696583ca38d5d82de58865a4a27 100755 --- a/r2s-bwmsgsv2.rb +++ b/r2s-bwmsgsv2.rb @@ -59,17 +59,17 @@ while true day_msg_count = redis.incr( "archived_message-#{ARGV[0]}-#{tai_yyyymmdd}-total" - ).then { |total| + ) - t = Time.now - puts "LOG %d.%09d: total msgs for %s-%s now at %s\n" % - [t.to_i, t.nsec, tai_yyyymmdd, ARGV[0], total] - } + t = Time.now + puts "LOG %d.%09d: total msgs for %s-%s now at %s\n" % + [t.to_i, t.nsec, tai_yyyymmdd, ARGV[0], day_msg_count] # TODO: do something with day_msg_count # TODO: print less stuff in here puts "TODO - got some stuff: " + timestamps_plus_json_blob + puts "TODO - daymsgcount: '#{day_msg_count}'" # add some timestamps to timestamps_plus_json_blob (our own) @@ -86,8 +86,15 @@ while true # if got HTTP 200, then: - # redis.set(...) with expiration of 3 days, including timestamps - # use key: archived_message-#{ARGV[0]}-#{tai_yyyymmdd}-#{day_msg_count} + # TODO: "archived_message-#{ARGV[0]}-#{tai_yyyymmdd}-#{day_msg_count}"? + # if exists, then fail, and leave thing on pending queue (not atomic) + + rv1 = redis.setex( + "archived_message-#{ARGV[0]}-#{tai_yyyymmdd}-#{day_msg_count}", + 259200, timestamps_plus_json_blob + ) + puts "TODO - rv1: " + rv1 + # TODO: confirm rv1 == 'OK' # confirm pending key has one element and e == timestamps_plus_json_blob # if so, then rpop pending_messages-#{ARGV[0]} and discard