Created
December 8, 2023 08:54
-
-
Save Pirosauro/62545d0c957e10b52083df5a928af329 to your computer and use it in GitHub Desktop.
tork Job middleware #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"os" | |
"github.com/runabol/tork/cli" | |
"github.com/runabol/tork/conf" | |
"github.com/runabol/tork/engine" | |
"github.com/rs/zerolog/log" | |
"github.com/runabol/tork" | |
"github.com/runabol/tork/middleware/job" | |
) | |
func main() { | |
if err := conf.LoadConfig(); err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
mw := func(next job.HandlerFunc) job.HandlerFunc { | |
return func(ctx context.Context, et job.EventType, j *tork.Job) error { | |
log.Debug(). | |
Msgf("received job %s at state %s (%s)", j.ID, j.State, et) | |
return next(ctx, et, j) | |
} | |
} | |
engine.RegisterJobMiddleware(mw) | |
if err := cli.New().Run(); err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Successful job
Relevant output from middleware (no STATE_CHANGE -> RUNNING)