]> zdv.bktei.com Git - EVA-2020-02.git/blobdiff - exec/bklog-plan.org
doc(exec):Create coding plan for bklog, retire bkgpslog plan
[EVA-2020-02.git] / exec / bklog-plan.org
diff --git a/exec/bklog-plan.org b/exec/bklog-plan.org
new file mode 100644 (file)
index 0000000..9908efb
--- /dev/null
@@ -0,0 +1,58 @@
+* bklog task list
+** TODO Adjust filename duration dynamically
+2020-07-12T21:17Z; bktei> Currently, the "duration" component of the
+output filename for a given chunk is calculated from the ~bufferTTL~
+variable which does not necessarily reflect the amount of buffer lines
+being read into a given chunk, especially since lines of stdin may be
+received while synchronous processing occurs before a new
+~magicProcessWriteBuffer &~ job is spun off.
+
+A better way to specify the duration is to maintain a pair of
+timestamp varriables before each ~magicProcessWriteBuffer~ command is
+run. Within the asynchronous write job the time difference between the
+two time stamps may be evaluated in order to determine how much time
+has passed since the last write operation started. The last line read
+into the buffer when the ~while read~ loop finishes should be the most
+current value and so one of the two timestamps should be recorded
+then. The other time stamp should simply be the previous loop's
+timestamp value.
+
+For example:
+
+#+BEGIN_EXAMPLE
+    # MAIN LOOP: Run until script TTL seconds pass
+    bufferRound=0;
+    while [[ $SECONDS -lt "scriptTTL" ]]; do
+       vbm "STATUS:$fn:Starting buffer round:$bufferRound";
+       bufferTOD="$((SECONDS + bufferTTL))"; # Set buffer round time-of-death
+       # Consume stdin to fill buffer until buffer time-of-death (TOD) arrives
+       while read -r -t "$bufferTTL" line && [[ $SECONDS -lt "$bufferTOD" ]]; do
+           # Append line to buffer array
+           buffer+=("$line");
+       done;
+        #====BEGIN NEW CODE HERE====
+        bufferTimestampOld="$bufferTimestampNew";
+        bufferTimeStampNew="$(date --iso-8601=seconds)";
+        #====END NEW CODE HERE====
+       # Create dir_tmp if missing
+       if ! [[ -d "$dir_tmp" ]]; then
+           yell "ERROR:$fn:dir_tmp existence failure:$dir_tmp";
+           try mkdir "$dir_tmp" && vbm "DEBUG :$fn:Working dir recreated dir_tmp:$dir_tmp"; fi
+       # Update cmd_encrypt, cmd_encrypt_suffix
+       magicParseRecipients;
+       # Export buffer to asynchronous processing.
+       magicProcessWriteBuffer &
+       unset buffer; # Clear buffer array for next bufferRound
+       # Increment buffer round
+       ((bufferRound++));
+    done;
+#+END_EXAMPLE
+
+Then, within the ~magicProcessWriteBuffer()~ function, the difference
+in seconds between ~bufferTimestampOld~ and ~bufferTimestampNew~ may
+be calculated and an appropriate duration string generated from the
+~timeDuration()~ function.
+
+
+* bklog narrative
+