@vforsh/argus-client
v0.1.2
Published
Node-only client for Argus watcher list/logs APIs.
Downloads
60
Readme
@vforsh/argus-client
Node-only client for Argus watcher list/logs APIs.
Install
npm install @vforsh/argus-clientUsage
import { createArgusClient } from '@vforsh/argus-client'
const client = createArgusClient()
const list = await client.list()
const logs = await client.logs('app', { mode: 'preview', since: '10m', levels: ['error'] })API
createArgusClient(options?)
type ArgusClientOptions = {
registryPath?: string
ttlMs?: number
timeoutMs?: number
}registryPath: override registry path instead ofARGUS_REGISTRY_PATH/ default.ttlMs: staleness threshold for pruning watchers (defaultDEFAULT_TTL_MS).timeoutMs: default HTTP timeout; applied as 2s for status and 5s for logs.
client.list(options?)
type ListOptions = {
byCwd?: string
}
type ListResult = {
watcher: WatcherRecord
reachable: boolean
status?: StatusResponse
error?: string
}- Reads registry, prunes stale entries, pings
/statusfor each watcher. - Unreachable watchers are removed from the registry, but still returned with
reachable: falseanderror. byCwdfilters watchers bycwdsubstring (empty/whitespace treated as unset).
client.logs(watcherId, options?)
type LogsOptions = {
mode?: 'preview' | 'full'
levels?: string | LogLevel[]
match?: string | string[]
matchCase?: 'sensitive' | 'insensitive'
source?: string
after?: number
limit?: number
since?: string | number
}
type LogsResult = {
events: LogEvent[]
nextAfter: number
}mode: 'preview'(default) returns events withargsbounded viapreviewValue.mode: 'full'returns raw events from the watcher.levelsaccepts comma-separated string or array; maps to watcher/logsquery.matchaccepts regex patterns (string or array); multiple patterns use OR semantics.matchCasecontrols regex case-sensitivity (insensitiveby default server-side).sourcefilters byLogEvent.sourcesubstring.sinceaccepts a duration string (e.g."10m","2h","30s") or a duration in ms.
Errors
- Throws on invalid inputs (
since,after,limit). - Throws if the watcher id is not in the registry.
- If the watcher is unreachable, the registry entry is removed and the call throws.
Notes
list()andlogs()prune stale registry entries before doing work.- This package is Node-only and uses the Argus registry on disk.
