chore(TODO):Update task list
[EVA-2020-02.git] / exec / bklog-plan.org
CommitLineData
e879cdc3 1* bklog task list
b773158a
SBS
2** DONE Adjust filename duration dynamically
3 CLOSED: [2020-07-14 Tue 22:17]
e879cdc3
SBS
42020-07-12T21:17Z; bktei> Currently, the "duration" component of the
5output filename for a given chunk is calculated from the ~bufferTTL~
6variable which does not necessarily reflect the amount of buffer lines
7being read into a given chunk, especially since lines of stdin may be
8received while synchronous processing occurs before a new
9~magicProcessWriteBuffer &~ job is spun off.
10
11A better way to specify the duration is to maintain a pair of
12timestamp varriables before each ~magicProcessWriteBuffer~ command is
13run. Within the asynchronous write job the time difference between the
14two time stamps may be evaluated in order to determine how much time
15has passed since the last write operation started. The last line read
16into the buffer when the ~while read~ loop finishes should be the most
17current value and so one of the two timestamps should be recorded
18then. The other time stamp should simply be the previous loop's
19timestamp value.
20
21For example:
22
23#+BEGIN_EXAMPLE
24 # MAIN LOOP: Run until script TTL seconds pass
25 bufferRound=0;
26 while [[ $SECONDS -lt "scriptTTL" ]]; do
27 vbm "STATUS:$fn:Starting buffer round:$bufferRound";
28 bufferTOD="$((SECONDS + bufferTTL))"; # Set buffer round time-of-death
29 # Consume stdin to fill buffer until buffer time-of-death (TOD) arrives
30 while read -r -t "$bufferTTL" line && [[ $SECONDS -lt "$bufferTOD" ]]; do
31 # Append line to buffer array
32 buffer+=("$line");
33 done;
34 #====BEGIN NEW CODE HERE====
35 bufferTimestampOld="$bufferTimestampNew";
36 bufferTimeStampNew="$(date --iso-8601=seconds)";
37 #====END NEW CODE HERE====
38 # Create dir_tmp if missing
39 if ! [[ -d "$dir_tmp" ]]; then
40 yell "ERROR:$fn:dir_tmp existence failure:$dir_tmp";
41 try mkdir "$dir_tmp" && vbm "DEBUG :$fn:Working dir recreated dir_tmp:$dir_tmp"; fi
42 # Update cmd_encrypt, cmd_encrypt_suffix
43 magicParseRecipients;
44 # Export buffer to asynchronous processing.
45 magicProcessWriteBuffer &
46 unset buffer; # Clear buffer array for next bufferRound
47 # Increment buffer round
48 ((bufferRound++));
49 done;
50#+END_EXAMPLE
51
52Then, within the ~magicProcessWriteBuffer()~ function, the difference
53in seconds between ~bufferTimestampOld~ and ~bufferTimestampNew~ may
54be calculated and an appropriate duration string generated from the
55~timeDuration()~ function.
56
b773158a
SBS
572020-07-14T22:17:16Z; bktei> Initial adjustment of SECONDS
58implemented. Ongoing monitoring of end time of each buffer round
59~while read~ loop checked.
60** DONE Update ~SECONDS~ variable during while read loop
61 CLOSED: [2020-07-14 Tue 16:22]
89c5dead
SBS
622020-07-14T00:58Z; bktei> The starting timestamps of each output file
63still drifts against system time. Although the ~while read~ loop does
64not lose data, the drift causes the output files to be named weirdly.
e879cdc3 65
89c5dead
SBS
66A possible solution is to correct the ~SECONDS~ variable against the
67current system time. Because ~date~ calls are slow, this correction
68should not be made after every line. At a minimum, the correction
69should occur once per buffer round, possibly after the buffer round
70has completed. If more frequent corrections are required, then the
71number of lines being read in each buffer round should be tracked and
72a modulus comparison may be implemented within the ~while read~ loop
73so that a correction is made after some fraction of the expected lines
74to be read are read.
b773158a
SBS
75
762020-07-14T16:21Z; bktei> I ran a test to see if SECONDS drifts and it
77does not. The lag is caused by other synchronous commands. The
78solution will be to adjust the variables against which SECONDS is
79compared.
ceb6d15e 80** TODO Account for "early-exit" bug in input script
b773158a
SBS
81*** 2020-07-14T03:00Z; bktei>
82What happens if the script piping its stdout into ~bklog~ immediately
83exits without providing any stdout (ex: a python script with a missing
84module)? ~bklog~ should be able to detect the latest exit code and
85exit early. It should also be able to detect if the incoming pipe is
86closed.
87
88*** 2020-07-14T22:25Z; bktei>
89Possible solution using ~dd~, ~od~, and ~if [ -z string ]~ [[https://unix.stackexchange.com/a/33055][here]].
0301313a
SBS
90** TODO Support configuration file for storing options
91*** 2020-07-15T23:48Z;bktei>
92Support storing options in a ~$HOME/.config/bklog/options.conf~ file
93so individual calls to ~bklog~ don't have to be so long. Aliases can
94be used instead to make ~bklog~ calls shorter, but cron jobs don't
95necessarily source alias files. Explicitly reading options from a
96configuration file would be more reliable, although it complicates
97usage of ~bklog~.
8151f8ce
SBS
98*** 2020-07-20T01:45Z; bktei>
99It should be possible to specify options via a configuration file
100stored within a ~~/.config/~ directory instead of specifying options
101each time ~bklog~ is called. This feature would simplify use of
102~bklog~ in situations where specifying options is tiresome and only
103quick / one-off use of ~bklog~ is needed.
e879cdc3
SBS
104* bklog narrative
105