fix day total increment, add archived_message save
Denver Gingerich
created
Fix incrementing of the daily message total so that it doesn't use the
EMPromise-style code imported in 07bcf9c - this code works elsewhere,
but we're not using EMPromise in this file so use the more sequential
method of coding (that works here) instead.
Also add the saving of the passed-on messages to the archived_message
keys. This is done with the 3-day (259,200 seconds) expiration per
the just-removed comment.
The code as of this commit has been tested now, so it does actually
run - the previously version (in 07bcf9c) did not run due to the
aforementioned EMPromise issue.
@@ -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