summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-sched/job.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/codeberg.org/gruf/go-sched/job.go')
-rw-r--r--vendor/codeberg.org/gruf/go-sched/job.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/vendor/codeberg.org/gruf/go-sched/job.go b/vendor/codeberg.org/gruf/go-sched/job.go
index 66e24fe9a..7831a39bd 100644
--- a/vendor/codeberg.org/gruf/go-sched/job.go
+++ b/vendor/codeberg.org/gruf/go-sched/job.go
@@ -1,6 +1,9 @@
package sched
import (
+ "reflect"
+ "strconv"
+ "strings"
"time"
"codeberg.org/gruf/go-atomics"
@@ -97,3 +100,19 @@ func (job *Job) Run(now time.Time) {
}()
job.call(now)
}
+
+// String provides a debuggable string representation of Job including ID, next time and Timing type.
+func (job *Job) String() string {
+ var buf strings.Builder
+ buf.WriteByte('{')
+ buf.WriteString("id=")
+ buf.WriteString(strconv.FormatUint(job.id, 10))
+ buf.WriteByte(' ')
+ buf.WriteString("next=")
+ buf.WriteString(job.next.Load().Format(time.StampMicro))
+ buf.WriteByte(' ')
+ buf.WriteString("timing=")
+ buf.WriteString(reflect.TypeOf(job.timing).String())
+ buf.WriteByte('}')
+ return buf.String()
+}