# README
go-utils
utilities for golang development
JobQ
A queue for time job execution. It is also a retry queue.
Example
sec := time.NewTicker(time.Second)
t := time.NewTicker(10*time.Second)
q := NewJobQ()
for {
select {
case tick := <-sec.C:
log.Printf("[%v] - Intel<%s>\n", tick, q.Intel())
case job := <- q.JobChan:
log.Println("An Job is about to execute", job)
case <-t.C:
jid := rand.Int()
deltaSec := rand.Int63n(4) + 1
ttl := deltaSec * int64(time.Second)
ddl := time.Now().Add(time.Duration(deltaSec) * time.Second).UnixNano()
log.Printf("[%v] - Add Job<%d, %d>\n", ts, jid, ttl)
// add a job with deadline <ddl>
q.AddJob(jid, ddl)
/* or you could retry a job after a ttl
q.Retry(jid, ttl)
*/
}
}
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
package heap is a package implements min-heap with customized comparator and validator
*/.
Package hstats is short for host stats aiming to record host stats metrics.
No description provided by the author
No description provided by the author
No description provided by the author
Package queue implements a thread-safe JobQ and ordinary Queue:
JobQ is for job execution with ddl(deadline)
which is based on [GoDs](https://github.com/emirpasic/gods) from emirpasic.
Package respond is a helper for gin response It encourages to use package go-utils/errors for error code definition.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author