MCPcopy Create free account
hub / github.com/BryanMwangi/pine / main

Function main

Examples/CronExample/main.go:12–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10)
11
12func main() {
13 // Initialize a new Pine app
14 app := pine.New()
15
16 task := cron.Job{
17 Fn: logHello,
18 Time: 6 * time.Second,
19 }
20 task2 := cron.Job{
21 Fn: logError,
22 Time: 1 * time.Second,
23 }
24 task3 := cron.Job{
25 Fn: panicError,
26 Time: 3 * time.Second,
27 }
28
29 task4 := cron.Job{
30 Fn: logHello2,
31 Time: 3 * time.Second,
32 }
33
34 task5 := cron.Job{
35 Fn: nestedPanicError,
36 Time: 3 * time.Second,
37 }
38
39 task6 := cron.Job{
40 Fn: cronError,
41 Time: 3 * time.Second,
42 }
43
44 newCron := cron.New(cron.Config{
45 RestartOnError: true,
46 RetryAttempts: 3,
47 })
48
49 newCron.AddJobs(task, task2, task3, task4, task5, task6)
50 newCron.Start()
51
52 // Define a route for the GET method on the root path '/hello'
53 app.Get("/hello", func(c *pine.Ctx) error {
54 return c.SendString("Hello World!")
55 })
56
57 // Start the server on port 3000
58 log.Fatal(app.Start(":3001"))
59}
60
61func logHello() error {
62 fmt.Println("Hello World!")

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
NewFunction · 0.92
AddJobsMethod · 0.80
SendStringMethod · 0.80
StartMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected