Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions code/segmentedtickerplant/stplog.q
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ endofperiod:{[currentpd;nextpd;data]
// stp runs function to send out end of period messages and roll logs
// eop log roll is stopped if eod is also going to be triggered (roll is not stopped in SCTP)
stpeoperiod:{[currentpd;nextpd;data;rolllogs]
.lg.o[`endofperiod;"flushing remaining data to subscribers and clearing tables"];
.stpps.pubclear[.stplg.t];
.lg.o[`stpeoperiod;"passing on endofperiod message to subscribers"];
.stpps.endp[currentpd;nextpd;data]; // sends endofperiod message to subscribers
currperiod::nextperiod; // increments current period
Expand All @@ -210,22 +212,15 @@ periodrollover:{[data]
rolllog[multilog;dldir;rolltabs;data`p];
}

// endofday function defined in SCTP
// passes on eod messages to subscribers and rolls logs
// common eod for STP and SCTP to send out eod messages and roll logs
endofday:{[date;data]
.lg.o[`endofday;"flushing remaining data to subscribers and clearing tables"];
.stpps.pubclear[.stplg.t];
.lg.o[`endofday;"executing end of day for ",.Q.s1 .eodtime.d];
.stpps.end[date;data]; // sends endofday message to subscribers
dayrollover[data];
}

// STP runs function to send out eod messages and roll logs
stpeod:{[date;data]
.lg.o[`stpeod;"executing end of day for ",.Q.s1 .eodtime.d];
.stpps.end[date;data]; // sends endofday message to subscribers
dayrollover[data];
}

// common eod log rolling logic for STP and SCTP
dayrollover:{[data]
if[(data`p)>.eodtime.nextroll:.eodtime.getroll[data`p];
Expand All @@ -248,7 +243,7 @@ checkends:{
// check for endofperiod
if[nextperiod < x1:x+.eodtime.dailyadj; stpeoperiod[.stplg`currperiod;.stplg`nextperiod;.stplg.endofdaydata[],(enlist `p)!enlist x1;not .eodtime.nextroll < x]];
// check for endofday
if[.eodtime.nextroll < x;if[.eodtime.d<("d"$x)-1;system"t 0";'"more than one day?"]; stpeod[.eodtime.d;.stplg.endofdaydata[],(enlist `p)!enlist x]];
if[.eodtime.nextroll < x;if[.eodtime.d<("d"$x)-1;system"t 0";'"more than one day?"]; endofday[.eodtime.d;.stplg.endofdaydata[],(enlist `p)!enlist x]];
};

init:{[dbname]
Expand Down