File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ func (DummyMetrics) QueueLost() {}
2222// It just leaks data to the trash.
2323type 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 }
Original file line number Diff line number Diff line change 11module github.com/koykov/queue
22
3- go 1.16
3+ go 1.18
44
55require github.com/koykov/bitset v1.0.0
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package queue
33// Interface describes queue interface.
44type 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.
1818type Worker interface {
1919 // Do process the item.
20- Do (x interface {} ) error
20+ Do (x any ) error
2121}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package queue
33// Logger is an interface of logger interface.
44// Prints verbose messages.
55type 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}
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ type Queue struct {
6363
6464// item is a wrapper for queue element with retries count.
6565type 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 {
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments