Skip to content

Commit ef86a68

Browse files
authored
Merge pull request #6 from koykov/goup1.18
upgrade go to 1.18
2 parents 6fc3dfa + b440e4d commit ef86a68

8 files changed

Lines changed: 20 additions & 20 deletions

File tree

dummy.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ func (DummyMetrics) QueueLost() {}
2222
// It just leaks data to the trash.
2323
type DummyDLQ struct{}
2424

25-
func (DummyDLQ) Enqueue(_ interface{}) error { return nil }
26-
func (DummyDLQ) Size() int { return 0 }
27-
func (DummyDLQ) Capacity() int { return 0 }
28-
func (DummyDLQ) Rate() float32 { return 0 }
29-
func (DummyDLQ) Close() error { return nil }
25+
func (DummyDLQ) Enqueue(_ any) error { return nil }
26+
func (DummyDLQ) Size() int { return 0 }
27+
func (DummyDLQ) Capacity() int { return 0 }
28+
func (DummyDLQ) Rate() float32 { return 0 }
29+
func (DummyDLQ) Close() error { return nil }

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/koykov/queue
22

3-
go 1.16
3+
go 1.18
44

55
require github.com/koykov/bitset v1.0.0

interface.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package queue
33
// Interface describes queue interface.
44
type Interface interface {
55
// Enqueue puts item to the queue.
6-
Enqueue(x interface{}) error
6+
Enqueue(x any) error
77
// Size return actual size of the queue.
88
Size() int
99
// Capacity return max size of the queue.
@@ -17,5 +17,5 @@ type Interface interface {
1717
// Worker describes queue worker interface.
1818
type Worker interface {
1919
// Do process the item.
20-
Do(x interface{}) error
20+
Do(x any) error
2121
}

logger.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package queue
33
// Logger is an interface of logger interface.
44
// Prints verbose messages.
55
type Logger interface {
6-
Printf(format string, v ...interface{})
7-
Print(v ...interface{})
8-
Println(v ...interface{})
6+
Printf(format string, v ...any)
7+
Print(v ...any)
8+
Println(v ...any)
99
}

queue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type Queue struct {
6363

6464
// item is a wrapper for queue element with retries count.
6565
type item struct {
66-
payload interface{}
66+
payload any
6767
retries uint32
6868
dexpire int64 // Delayed execution expire time (Unix ns timestamp).
6969
}
@@ -213,7 +213,7 @@ func (q *Queue) init() {
213213
}
214214

215215
// Enqueue puts x to the queue.
216-
func (q *Queue) Enqueue(x interface{}) error {
216+
func (q *Queue) Enqueue(x any) error {
217217
q.once.Do(q.init)
218218
// Check if enqueue is possible.
219219
if status := q.getStatus(); status == StatusClose || status == StatusFail {

worker/async_chain.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ func (w *AsyncChain) Bind(workers ...queue.Worker) *AsyncChain {
2424

2525
// Do asynchronously process the item.
2626
// Each worker in chain will be called for processing. AsyncChain will stop processing on first failed worker.
27-
func (w AsyncChain) Do(x interface{}) (err error) {
27+
func (w *AsyncChain) Do(x any) (err error) {
2828
var (
2929
wg sync.WaitGroup
3030
ef uint32
3131
)
32-
for i := 0; i < len(w); i++ {
32+
for i := 0; i < len(*w); i++ {
3333
wg.Add(1)
3434
go func(i int) {
3535
defer wg.Done()
36-
if err1 := w[i].Do(x); err1 != nil {
36+
if err1 := (*w)[i].Do(x); err1 != nil {
3737
if atomic.AddUint32(&ef, 1) == 1 {
3838
err = err1
3939
}

worker/chain.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ func (w *Chain) Bind(workers ...queue.Worker) *Chain {
1919

2020
// Do process the item.
2121
// Each worker in chain will be called for processing. Chain will stop processing on first failed worker.
22-
func (w Chain) Do(x interface{}) (err error) {
23-
for i := 0; i < len(w); i++ {
24-
if err = w[i].Do(x); err != nil {
22+
func (w *Chain) Do(x any) (err error) {
23+
for i := 0; i < len(*w); i++ {
24+
if err = (*w)[i].Do(x); err != nil {
2525
return
2626
}
2727
}

worker/transit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TransitTo(queue queue.Interface) *Transit {
1313
return &w
1414
}
1515

16-
func (w Transit) Do(x interface{}) error {
16+
func (w Transit) Do(x any) error {
1717
if w.queue == nil {
1818
return queue.ErrNoQueue
1919
}

0 commit comments

Comments
 (0)