Getting started with ppacer
Intro
To begin, we’ll set up new Go project, install ppacer and run hello world
example.
Installing ppacer
Hello World
Now, let’s proceed to initiate the ppacer with a single DAG. Start by creating
a file named main.go
with the following content:
Now we can compile and run our program.
Upon running, you should see a bunch of INFO
logs from ppacer Scheduler.
Please feel free to skip those logs and go straight to the UI at
http://localhost:9322.
Explanations
So what actually happened in our program? On high level we defined a DAG which
prints messages in particular order and runs each 10 seconds.
Let’s break down the main.go
file.
-
Import the Go standard and ppacer packages:
-
Define constants for ppacer Scheduler and UI ports:
-
The
main
function inmain
package is the program entry point in Go. -
Define the required context for the ppacer Scheduler:
-
Initialize the DAG registry and add new DAG from
printDAG
function: -
Spin off the ppacer UI in a separate goroutine (so it can run in parallel to the Scheduler)
-
Start the ppacer Scheduler (also in the form of an HTTP server) with the default configuration for given context, DAG registry and port:
-
The
printDAG
function defines a DAG for printing messages in particular order. Details on DAGs,Tasks
and schedules can be found further in the documentation.
Complete example
The whole source code for above example can be found in here: github.com/ppacer/examples.