Package dev.dokimos.server.client
Class DokimosServerReporter
java.lang.Object
dev.dokimos.server.client.DokimosServerReporter
- All Implemented Interfaces:
Reporter,AutoCloseable
An async HTTP implementation of
Reporter that sends experiment
results to a Dokimos server.
Items are queued and sent in batches by a background thread to reduce HTTP overhead. Batches are sent when either 10 items are queued or 500ms have passed since the first item in the batch.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default API version used when not explicitly specified. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a new builder forDokimosServerReporter.voidclose()Flushes pending items and releases resources.voidcompleteRun(RunHandle handle, RunStatus status) Marks a run as complete.voidflush()Blocks until all pending items are sent.static DokimosServerReporterCreates a reporter from environment variables.voidreportItem(RunHandle handle, ItemResult result) Reports a single evaluated item.Starts a new experiment run.
-
Field Details
-
DEFAULT_API_VERSION
The default API version used when not explicitly specified.- See Also:
-
-
Method Details
-
builder
Creates a new builder forDokimosServerReporter.- Returns:
- a new builder
-
fromEnvironment
Creates a reporter from environment variables.Reads
DOKIMOS_SERVER_URLandDOKIMOS_PROJECT_NAMEfrom the environment. Optionally readsDOKIMOS_API_KEYfor authentication andDOKIMOS_API_VERSIONfor version pinning.- Returns:
- a configured reporter
- Throws:
IllegalStateException- if required environment variables are not set
-
startRun
Description copied from interface:ReporterStarts a new experiment run. -
reportItem
Description copied from interface:ReporterReports a single evaluated item.This is called after each item completes evaluation, not batched at the end.
- Specified by:
reportItemin interfaceReporter- Parameters:
handle- the run handle fromReporter.startRun(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>)result- the evaluated item result
-
completeRun
Description copied from interface:ReporterMarks a run as complete.- Specified by:
completeRunin interfaceReporter- Parameters:
handle- the run handle fromReporter.startRun(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>)status- the final status of the run
-
flush
public void flush()Description copied from interface:ReporterBlocks until all pending items are sent.This is important for async implementations to ensure all data is transmitted before the experiment returns.
-
close
public void close()Description copied from interface:ReporterFlushes pending items and releases resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceReporter
-