View Source F1Bot.Replay (f1_bot v0.7.0)

Given a base URL of a live timing dataset, this module takes care of downloading known .jsonStream datasets, pre-processes them into a single stream of live timing packets, and consecutively processes them using arbitrary implementations.

This module is flexible enough to support different use cases:

  • Silently replay the entire dataset in an inert/side-effect free fashion to obtain the final F1Session state for analysis purposes (see F1Bot.reload_session/2)

  • Quickly replay the dataset while using mock implementations of Discord module which prints the output to console. This allows us to see what messages would be sent to Discord if we were to run the bot in a live session (see Mix.Tasks.Backtest)

  • Fast forward to the session start (using :replay_while_fn to quickly process everything until we encounter a session started packet), then slowly replay the dataset in real time (again using :replay_while_fn to process narrow time slices of packets), allowing us to provide a demo environment for the bot which behaves as if it was running in a live session (see F1Bot.Replay.Server.start_demo_mode/1)

Replay state contains the following fields:

  • :session - the current F1Session state

  • :dataset - a list of unprocessed tuples, containing session timestamp in milliseconds, source .jsonStream name, session timestamp as DateTime, and live timing packet payload (unparsed); sorted by timestamp

  • :processed_packets - a number of processed packets, used for logging purposes

  • :total_packets - a total number of packets in the dataset, used for logging purposes

  • :base_ts - DateTime that denotes the start of the replay session, used to calculate the absolute timestamp of each packet in the dataset

Link to this section Summary

Functions

Resume replaying the dataset using the given replay state and options.

Given a URL to a live timing dataset, download the .jsonStream datasets and process them using the F1Session module, with or without side effects, up to an arbitrary point in time.

Link to this section Functions

Link to this function

replay_dataset(state, options)

View Source

Resume replaying the dataset using the given replay state and options.

For documentation on options, see start_replay/2.

Link to this function

start_replay(url, options)

View Source

Given a URL to a live timing dataset, download the .jsonStream datasets and process them using the F1Session module, with or without side effects, up to an arbitrary point in time.

options

Options

See F1Bot.Replay.Options for a list of available options.