go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/cron/job_scheduler_event.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package cron 9 10 import ( 11 "strings" 12 "time" 13 ) 14 15 // JobSchedulerEvent is an event. 16 type JobSchedulerEvent struct { 17 Phase string 18 JobName string 19 JobInvocation string 20 Parameters JobParameters 21 Err error 22 Elapsed time.Duration 23 } 24 25 // String implements fmt.Stringer. 26 func (e JobSchedulerEvent) String() string { 27 wr := new(strings.Builder) 28 wr.WriteString(e.Phase + " ") 29 wr.WriteString(e.JobName + " ") 30 wr.WriteString(e.JobInvocation + " ") 31 if e.Elapsed > 0 { 32 wr.WriteString(" (" + e.Elapsed.String() + ")") 33 } 34 if e.Err != nil { 35 wr.WriteString("failed") 36 } 37 return wr.String() 38 }