Liking cljdoc? Tell your friends :D

event-data-common.checkpoint

Checkpoint functionality for Agents. Allows setting of checkpoints and function to check if the checkpoint happened more than a period of time ago. Checkpoint identifiers are anything that can be converted to a string, and are hashed.

This is used so that Agents can run in continual loops, only re-trying when a given time period has elapsed, choosing which items to checkpoint on (e.g. per whole domain scan, or per newsfeed).

Doing it this way makes it possible to resume a scan in the face of a crash. It also means that we can add new domains in future, and the Reddit source could back-scan for that domain, regardless of others.

Checkpoints are stored as JSON in case we want to inspect them later. Longs stored as Strings because you can't really trust numbers in JSON.

Checkpoint functionality for Agents.
Allows setting of checkpoints and function to check if the checkpoint happened more than a period of time ago.
Checkpoint identifiers are anything that can be converted to a string, and are hashed.

This is used so that Agents can run in continual loops, only re-trying when a given time period has elapsed,
choosing which items to checkpoint on (e.g. per whole domain scan, or per newsfeed). 

Doing it this way makes it possible to resume a scan in the face of a crash. It also means that we can add new
domains in future, and the Reddit source could back-scan for that domain, regardless of others.

Checkpoints are stored as JSON in case we want to inspect them later.
Longs stored as Strings because you can't really trust numbers in JSON.
raw docstring

checkpoint-storeclj


floor-dateclj

(floor-date date period-ago)

If the supplied date is nil or earlier than the time-period, return the time-period-ago date.

If the supplied date is nil or earlier than the time-period, return the time-period-ago date.
raw docstring

get-checkpointclj

(get-checkpoint identifier)

For a given checkpoint, return the date time that it happened, or nil

For a given checkpoint, return the date time that it happened, or nil
raw docstring

get-floored-checkpoint-dateclj

(get-floored-checkpoint-date identifier period-ago)

Get the checkpoint date, limited to maximum period-ago.

Get the checkpoint date, limited to maximum period-ago.
raw docstring

has-time-elapsed?clj

(has-time-elapsed? identifier period-ago)

Has at least the given time elapsed since the last checkpoint for this identifier? If so, return the last date. If not, return nil.

Has at least the given time elapsed since the last checkpoint for this identifier?
If so, return the last date. If not, return nil.
raw docstring

hash-identifierclj

(hash-identifier identifier)

run-checkpointed!clj

(run-checkpointed! identifier since-period-ago floor-period-ago function)

Run the given function and set checkpoint with identifier if there hasn't been a checkpoint in the given time period. Call function with date of last run, or floor-period-ago if it never ran before

Run the given function and set checkpoint with identifier if there hasn't been a checkpoint in the given time period.
Call function with date of last run, or floor-period-ago if it never ran before
raw docstring

run-once-checkpointed!clj

(run-once-checkpointed! identifier function)

Run the supplied function with checkpoint identifier only once, ever.

Run the supplied function with checkpoint identifier only once, ever.
raw docstring

set-checkpoint!clj

(set-checkpoint! identifier)
(set-checkpoint! identifier time-value)

Set checkpoint with identifier to given time, or now.

Set checkpoint with identifier to given time, or now.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close