Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
github.skymusic.top/jorbriib/multiple-job-queue
Multiple Job Queue provides an API to process jobs in asynchronous way. Also, it allows you to defer the processing of a time-consuming task and creates a number of workers to parallelize the execution of each job.
The routing package is just a common Go module. You can install it as any other Go module.
go get github.com/jorbriib/multiple-job-queue
To get more information just review the official Go blog regarding this topic.
This is just a quick introduction, view the GoDoc for details.
Basic usage example in a web server:
package main
import (
mjq "github.com/jorbriib/multiple-job-queue"
"fmt"
"log"
"net/http"
"time"
)
type TestJob struct {
}
func (tj *TestJob) Handle() {
time.Sleep(2 * time.Second)
fmt.Println("Job handled")
}
func handler(w http.ResponseWriter, r *http.Request) {
dispatcher := mjq.GetDispatcher()
testJob1 := &TestJob{}
// Dispatch dispatches testJob1 to high queue
_ = dispatcher.Dispatch(testJob1, "high")
w.WriteHeader(200)
}
func main() {
// InitializeQueues creates a default queue with 1 worker
_ = mjq.InitializeQueues(1,
mjq.AddQueue("high", 4), // AddQueue creates a high queue with 4 workers
mjq.AddQueue("medium", 2),
mjq.AddQueue("low", 1))
http.HandleFunc("/job", handler)
log.Fatal(http.ListenAndServe(":8080", nil))
}
Basic usage example in a console command:
package main
import (
mjq "github.com/jorbriib/multiple-job-queue"
"math/rand"
)
func main() {
q := mjq.InitializeQueues(0,
mjq.AddQueue("high", 5),
mjq.AddQueue("medium", 2),
mjq.AddQueue("low", 1))
queues := []string{"high", "medium", "low"}
dispatcher := mjq.GetDispatcher()
for i := 0; i < 100; i++ {
randomQueue := rand.Intn(len(queues))
testJob1 := &TestJob{}
_ = dispatcher.Dispatch(testJob1, queues[randomQueue])
}
q.WaitUntilFinish()
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.