Class ::nsmcp::AccessLogIngestor

::nsmcp::AccessLogIngestor[i] create ... \
           [ -maxLineBytes:integer (default "65536") ] \
           [ -maxReadBytes:integer (default "16777216") ] \
           [ -maxSeconds:integer (default "2") ] \
           [ -mutex (default "") ] \
           [ -parser (default "::nsmcp::accessRecordParser") ] \
           [ -path:required path:required ] \
           [ -retentionSeconds:double (default "86400") ]

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

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::nsmcp::Object[i]
  • subclass: ::nsmcp::AccessAnalytics[i]
::nx::Class create ::nsmcp::AccessLogIngestor \
     -superclass ::nsmcp::Object

Methods (to be applied on instances)

  • ingest (scripted, public)

     <instance of nsmcp::AccessLogIngestor[i]> ingest [ from ] \
        [ allowHistory ]

    Ingest a bounded portion of the configured access logs. Validate the starting timestamp and serialize ingestion with the instance mutex; historical work is optional.

    Parameters:
    from (optional)
    Earliest epoch-second timestamp to ingest; empty uses the default recent window.
    allowHistory (optional, defaults to "false")
    Whether this pass may process historical sources. Defaults to 'false'.
    Returns:
    The ingestion result returned by the locked ingestion pass.

    Testcases:
    No testcase defined.
    if {$from eq ""} {
        set from [expr {[clock seconds]-3600}]
    }
    if {![string is entier -strict $from] || $from < 0} {
        error "expected an epoch-second window start"
    }
    ns_mutex lock ${:mutex}
    try {
        return [:ingestLocked $from $allowHistory]
    } finally {
        ns_mutex unlock ${:mutex}
    }
  • refresh (scripted, public)

     <instance of nsmcp::AccessLogIngestor[i]> refresh

    Run the scheduled bounded ingestion callback. Permit historical work and log ingestion failures without allowing a scheduler exception to escape.

    Returns:
    An empty callback result.

    Testcases:
    No testcase defined.
    # Scheduler callback performs bounded work in a separate thread.
    if {[catch {
        :ingest {} true
    } message]} {
        ns_log warning "nsmcp: access ingestion failed: $message"
    }
  • validateWindow (scripted, public)

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

    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.
    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