nsmcp::AccessLogIngestor method validateWindow (public)

 <instance of nsmcp::AccessLogIngestor[i]> validateWindow options

Defined in /usr/local/ns/tcl/nsmcp/access-analytics.tcl

Validate and resolve an access-summary time window. Apply supported-option checks, timestamp bounds and bucket-size limits before querying the cache.

Parameters:
options (required)
Tcl dictionary containing the operation options.
Returns:
The normalized window-options dictionary.

Testcases:
No testcase defined.
Source code:
foreach key [dict keys $options] {
    if {$key ni {from to bucketSeconds}} {
        error "unsupported summary option"
    }
}
set now [clock seconds]
set options [dict merge [dict create from [expr {$now-3600}] to $now bucketSeconds 60] $options]
foreach key {from to bucketSeconds} {
    if {![string is entier -strict [dict get $options $key]]} {
        error "expected integer epoch times and bucketSeconds"
    }
}
set from [dict get $options from]
set to [dict get $options to]
set size [dict get $options bucketSeconds]
if {$from >= $to || $to-$from > 86400 || $from < 0 || $to > $now || $size < 1 || $size > 3600 || ($size >= 60 && $size%60 != 0) || ($size < 60 && $size ni {1 5 10 15 30}) || (int(ceil(double($to)/$size))-($from/$size)) > 3600} {
    error "expected a window of at most 24 hours ending no later than now and at most 3600 buckets; bucketSeconds must be 1, 5, 10, 15, 30 or a multiple of 60 up to 3600"
}
return $options
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: