initial import
This commit is contained in:
42
example/beanstalk/consumer/consumer.go
Normal file
42
example/beanstalk/consumer/consumer.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"zero/core/stores/redis"
|
||||
"zero/dq"
|
||||
)
|
||||
|
||||
func main() {
|
||||
consumer := dq.NewConsumer(dq.DqConf{
|
||||
Beanstalks: []dq.Beanstalk{
|
||||
{
|
||||
Endpoint: "localhost:11300",
|
||||
Tube: "tube",
|
||||
},
|
||||
{
|
||||
Endpoint: "localhost:11301",
|
||||
Tube: "tube",
|
||||
},
|
||||
{
|
||||
Endpoint: "localhost:11302",
|
||||
Tube: "tube",
|
||||
},
|
||||
{
|
||||
Endpoint: "localhost:11303",
|
||||
Tube: "tube",
|
||||
},
|
||||
{
|
||||
Endpoint: "localhost:11304",
|
||||
Tube: "tube",
|
||||
},
|
||||
},
|
||||
Redis: redis.RedisConf{
|
||||
Host: "localhost:6379",
|
||||
Type: redis.NodeType,
|
||||
},
|
||||
})
|
||||
consumer.Consume(func(body []byte) {
|
||||
fmt.Println(string(body))
|
||||
})
|
||||
}
|
||||
40
example/beanstalk/producer/producer.go
Normal file
40
example/beanstalk/producer/producer.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"zero/dq"
|
||||
)
|
||||
|
||||
func main() {
|
||||
producer := dq.NewProducer([]dq.Beanstalk{
|
||||
{
|
||||
Endpoint: "localhost:11300",
|
||||
Tube: "tube",
|
||||
},
|
||||
{
|
||||
Endpoint: "localhost:11301",
|
||||
Tube: "tube",
|
||||
},
|
||||
{
|
||||
Endpoint: "localhost:11302",
|
||||
Tube: "tube",
|
||||
},
|
||||
{
|
||||
Endpoint: "localhost:11303",
|
||||
Tube: "tube",
|
||||
},
|
||||
{
|
||||
Endpoint: "localhost:11304",
|
||||
Tube: "tube",
|
||||
},
|
||||
})
|
||||
for i := 0; i < 5; i++ {
|
||||
_, err := producer.At([]byte(strconv.Itoa(i)), time.Now().Add(time.Second*10))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user