travis ci

This commit is contained in:
finley
2022-03-13 13:20:57 +08:00
parent 67d25d61e5
commit ebbd413ee4
4 changed files with 34 additions and 7 deletions

9
.travis.yml Normal file
View File

@@ -0,0 +1,9 @@
language: go
go:
- 1.16.x
before_install:
- sudo apt-get install redis-server; redis-server &
- go install github.com/mattn/goveralls@latest
script:
- $GOPATH/bin/goveralls -service=travis-ci

View File

@@ -1,5 +1,11 @@
# DelayQueue
![license](https://img.shields.io/github/license/HDT3213/delayqueue)
[![Build Status](https://travis-ci.com/HDT3213/delayqueue.svg?branch=master)](https://app.travis-ci.com/github/HDT3213/delayqueue)
[![Coverage Status](https://coveralls.io/repos/github/HDT3213/delayqueue/badge.svg?branch=master)](https://coveralls.io/github/HDT3213/delayqueue?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/HDT3213/delayqueue)](https://goreportcard.com/report/github.com/HDT3213/delayqueue)
[![Go Reference](https://pkg.go.dev/badge/github.com/hdt3213/delayqueue.svg)](https://pkg.go.dev/github.com/hdt3213/delayqueue)
DelayQueue is a message queue supporting delayed/scheduled delivery based on redis.
DelayQueue guarantees to deliver at least once.
@@ -76,3 +82,12 @@ WithFetchLimit(limit uint)
```
WithFetchLimit limits the max number of messages at one time
```
WithDefaultRetryCount(count uint)
```
WithDefaultRetryCount customizes the max number of retry, it effects of messages in this queue
use WithRetryCount during DelayQueue.SendScheduleMsg or DelayQueue.SendDelayMsg to specific retry count of particular message

View File

@@ -29,7 +29,7 @@ type DelayQueue struct {
maxConsumeDuration time.Duration
msgTTL time.Duration
defaultRetryCount int
defaultRetryCount uint
fetchInterval time.Duration
fetchLimit uint
}
@@ -92,6 +92,13 @@ func (q *DelayQueue) WithFetchLimit(limit uint) *DelayQueue {
return q
}
// WithDefaultRetryCount customizes the max number of retry, it effects of messages in this queue
// use WithRetryCount during DelayQueue.SendScheduleMsg or DelayQueue.SendDelayMsg to specific retry count of particular message
func (q *DelayQueue) WithDefaultRetryCount(count uint) *DelayQueue {
q.defaultRetryCount = count
return q
}
func (q *DelayQueue) genMsgKey(idStr string) string {
return "dp:" + q.name + ":msg:" + idStr
}
@@ -127,7 +134,7 @@ func (q *DelayQueue) SendScheduleMsg(payload string, t time.Time, opts ...interf
for _, opt := range opts {
switch o := opt.(type) {
case retryCountOpt:
retryCount = int(o)
retryCount = uint(o)
}
}
// generate id

View File

@@ -71,7 +71,7 @@ func TestDelayQueue_StopConsume(t *testing.T) {
queue.StopConsume()
}
return true
})
}).WithDefaultRetryCount(1)
for i := 0; i < size; i++ {
err := queue.SendDelayMsg(strconv.Itoa(i), 0)
if err != nil {
@@ -102,7 +102,3 @@ func TestIDOverflow(t *testing.T) {
}
}
}
func TestDelayQUeu(t *testing.T) {
}