Package dev.dokimos.server.client
Class DokimosServerReporter
java.lang.Object
dev.dokimos.server.client.DokimosServerReporter
- All Implemented Interfaces:
Reporter,AutoCloseable
Async HTTP
Reporter that sends experiment results to a Dokimos server.
Items are queued and sent in batches of up to 10 items or every 500ms by a background thread. Requests use exponential-backoff retries (3 attempts) and idempotency keys so retried POSTs deduplicate server-side.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder forDokimosServerReporter.static final recordDescribes a batch of items permanently dropped after all delivery retries were exhausted. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbuilder()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:DOKIMOS_SERVER_URLandDOKIMOS_PROJECT_NAMEare required;DOKIMOS_API_KEYandDOKIMOS_API_VERSIONare optional.intNumber of items permanently dropped after exhausting all delivery retries.voidreportItem(RunHandle handle, ItemResult result) Reports a single evaluated item.Starts a new experiment run.
-
Field Details
-
DEFAULT_API_VERSION
Default API version when none is specified.- See Also:
-
-
Method Details
-
builder
New builder forDokimosServerReporter. -
fromEnvironment
Creates a reporter from environment variables:DOKIMOS_SERVER_URLandDOKIMOS_PROJECT_NAMEare required;DOKIMOS_API_KEYandDOKIMOS_API_VERSIONare optional.- Throws:
IllegalStateException- if a required variable is missing
-
getFailedItemCount
public int getFailedItemCount()Number of items permanently dropped after exhausting all delivery retries.- Returns:
- the count of items that could not be delivered to the server
-
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
-