This repo contains a tutorial that introduces developers to the replay framework.
Each sub-folder contains a simple go program. Some are purely examples and can just be studied and run with go run
.
Others contain TODO(you)
that must completed before the program will run successfully.
- 00_helloworld
- 01_typedhello
- 02_signalhello
- 03_outputhello
- 04_restarthello
- 05_cron
- 06_appendonlylog
- 07_makertrade
- 08_sparkline
- 09_parentjob
- 10_distributed
- 11_sharding
- versioning
- best effort activity consumers
-
Read the replay docs first (can skip Under the hood)
-
Read each exercise from top to bottom (including comments).
-
Running the programs can be done in IDE's supporting
go:generate
or from the command line:
go run github.com/corverroos/replaytutorial/00_helloworld
# Exit early with Ctrl-C to test restart robustness
- Regularly install the latest
typedreplay
code generation tool:
go install github.com/corverroos/replay/typedreplay/cmd/typedreplay@latest
- Some exercises contain
//showme:hidden foo
directives associated with aTODO(you)
instruction. Executing the followinggo:generate
command will show the next 1 solution in the go file. Note that the-hide
flag will hide the solutions.
//go:generate go run ../lib/showme 1
-
This tutorial assumes a mysql DB is accessible at
mysql://root@unix(/tmp/mysql.sock)/
. If not specify the connection url viadb_url
. Note it creates a long-lived database calledreplay_tutorial
. Use the flagdb_refresh
to clear the database. -
Experiment!