![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/robinjoseph08/redisqueue/v2
redisqueue
provides a producer and consumer of a queue that uses Redis
streams.
Producer
struct to make enqueuing messages easy.Consumer
struct to make processing messages concurrenly.SIGINT
and SIGTERM
) to let in-flight
messages complete.redisqueue
requires a Go version with Modules support and uses import
versioning. So please make sure to initialize a Go module before installing
redisqueue
:
go mod init github.com/my/repo
go get github.com/robinjoseph08/redisqueue/v2
Import:
import "github.com/robinjoseph08/redisqueue/v2"
Here's an example of a producer that inserts 1000 messages into a queue:
package main
import (
"fmt"
"github.com/robinjoseph08/redisqueue/v2"
)
func main() {
p, err := redisqueue.NewProducerWithOptions(&redisqueue.ProducerOptions{
StreamMaxLength: 10000,
ApproximateMaxLength: true,
})
if err != nil {
panic(err)
}
for i := 0; i < 1000; i++ {
err := p.Enqueue(&redisqueue.Message{
Stream: "redisqueue:test",
Values: map[string]interface{}{
"index": i,
},
})
if err != nil {
panic(err)
}
if i%100 == 0 {
fmt.Printf("enqueued %d\n", i)
}
}
}
And here's an example of a consumer that reads the messages off of that queue:
package main
import (
"fmt"
"time"
"github.com/robinjoseph08/redisqueue/v2"
)
func main() {
c, err := redisqueue.NewConsumerWithOptions(&redisqueue.ConsumerOptions{
VisibilityTimeout: 60 * time.Second,
BlockingTimeout: 5 * time.Second,
ReclaimInterval: 1 * time.Second,
BufferSize: 100,
Concurrency: 10,
})
if err != nil {
panic(err)
}
c.Register("redisqueue:test", process)
go func() {
for err := range c.Errors {
// handle errors accordingly
fmt.Printf("err: %+v\n", err)
}
}()
fmt.Println("starting")
c.Run()
fmt.Println("stopped")
}
func process(msg *redisqueue.Message) error {
fmt.Printf("processing message: %v\n", msg.Values["index"])
return nil
}
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.