Skip to Content

Features

Batching and flush

When Dock sends your captures, and how to make sure none are lost when your process exits.

capture doesn't make a network call. It adds the event to a buffer in your process, and Dock sends the buffer to Docklee in batches. Your app never waits on Docklee to capture.

Short-lived processes such as scripts, jobs, and serverless functions must flush or close Dock before they exit. Events still in the buffer are never sent.

When a batch is sent

TriggerPythonTypeScript
The buffer reaches buffer_size eventsYesYes
Every flushInterval millisecondsNoYes, every 5,000 by default
You call flush_sync() or flush()YesYes
You call close()YesYes

Flush and close

from docklee import Dock

dock = Dock(buffer_size=25)
for message in messages:
    dock.capture(message, type="conversation")

result = dock.flush_sync()
MethodPythonTypeScript
Send the buffer and waitflush_sync(), or await flush()await flush()
Send the buffer and stopawait close()await close()

In TypeScript, Dock runs a timer while it's open. Call close() when you're done so your process can exit.

When a batch fails

With flush_sync() in Python and flush() in TypeScript, a failed batch goes back into the buffer and is sent with the next flush. Both return the batch result on success, and None or null on failure.

Before giving up, the SDK retries timeouts, connection errors, and the statuses 408, 409, 429, 500, 502, 503, and 504. It waits 0.5 seconds before the first retry and doubles the wait each time, up to 8 seconds.

Tuning

SettingPythonTypeScriptDefault
Events per batchbuffer_sizebufferSize10
Timer intervalnoneflushInterval5000 milliseconds
Retries per requestmax_retriesmaxRetries3
Request timeouttimeout (seconds)timeout (milliseconds)30 seconds

A batch holds up to 100 events, so keep buffer_size at 100 or below.

Next steps

Your captures are reaching Docklee. See what it does with them next.

On this page