Jade is a Go package that provides features for managing tasks goroutine with different statuses such as pending, completed, and failed.
To use Jade in your Go project, you can simply install it using go get
:
go get github.com/refaldyrk/jade
Import Jade package in your Go code:
import "github.com/refaldyrk/jade"
You can create a new task using the NewTask
function:
task := jade.Task{
Id: 1,
Name: "task-1",
Status: jade.StatusPending,
}
newTask := jade.NewTask(task)
You can change the status of a task using the SetStatus
method:
newTask.SetStatus(jade.StatusCompleted)
You can listen for task status changes using the Listen
function:
go jade.Init()
listen := jade.Listen()
go func() {
for t := range listen {
switch t.GetStatus() {
case jade.StatusPending:
fmt.Println("Task ", t.Name, "Is", t.GetStatus())
case jade.StatusCompleted:
fmt.Println("Task ", t.Name, "Is", t.GetStatus())
case jade.StatusFailed:
fmt.Println("Task ", t.Name, "Is", t.GetStatus())
}
}
}()
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or create a pull request.
In Folder Example Hehe