Skip to content

Commit

Permalink
Merge pull request #6 from koykov/goup1.18
Browse files Browse the repository at this point in the history
upgrade go to 1.18
  • Loading branch information
koykov authored Apr 21, 2023
2 parents 6fc3dfa + b440e4d commit ef86a68
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func (DummyMetrics) QueueLost() {}
// It just leaks data to the trash.
type DummyDLQ struct{}

func (DummyDLQ) Enqueue(_ interface{}) error { return nil }
func (DummyDLQ) Size() int { return 0 }
func (DummyDLQ) Capacity() int { return 0 }
func (DummyDLQ) Rate() float32 { return 0 }
func (DummyDLQ) Close() error { return nil }
func (DummyDLQ) Enqueue(_ any) error { return nil }
func (DummyDLQ) Size() int { return 0 }
func (DummyDLQ) Capacity() int { return 0 }
func (DummyDLQ) Rate() float32 { return 0 }
func (DummyDLQ) Close() error { return nil }
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/koykov/queue

go 1.16
go 1.18

require github.com/koykov/bitset v1.0.0
4 changes: 2 additions & 2 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package queue
// Interface describes queue interface.
type Interface interface {
// Enqueue puts item to the queue.
Enqueue(x interface{}) error
Enqueue(x any) error
// Size return actual size of the queue.
Size() int
// Capacity return max size of the queue.
Expand All @@ -17,5 +17,5 @@ type Interface interface {
// Worker describes queue worker interface.
type Worker interface {
// Do process the item.
Do(x interface{}) error
Do(x any) error
}
6 changes: 3 additions & 3 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package queue
// Logger is an interface of logger interface.
// Prints verbose messages.
type Logger interface {
Printf(format string, v ...interface{})
Print(v ...interface{})
Println(v ...interface{})
Printf(format string, v ...any)
Print(v ...any)
Println(v ...any)
}
4 changes: 2 additions & 2 deletions queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Queue struct {

// item is a wrapper for queue element with retries count.
type item struct {
payload interface{}
payload any
retries uint32
dexpire int64 // Delayed execution expire time (Unix ns timestamp).
}
Expand Down Expand Up @@ -213,7 +213,7 @@ func (q *Queue) init() {
}

// Enqueue puts x to the queue.
func (q *Queue) Enqueue(x interface{}) error {
func (q *Queue) Enqueue(x any) error {
q.once.Do(q.init)
// Check if enqueue is possible.
if status := q.getStatus(); status == StatusClose || status == StatusFail {
Expand Down
6 changes: 3 additions & 3 deletions worker/async_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ func (w *AsyncChain) Bind(workers ...queue.Worker) *AsyncChain {

// Do asynchronously process the item.
// Each worker in chain will be called for processing. AsyncChain will stop processing on first failed worker.
func (w AsyncChain) Do(x interface{}) (err error) {
func (w *AsyncChain) Do(x any) (err error) {
var (
wg sync.WaitGroup
ef uint32
)
for i := 0; i < len(w); i++ {
for i := 0; i < len(*w); i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
if err1 := w[i].Do(x); err1 != nil {
if err1 := (*w)[i].Do(x); err1 != nil {
if atomic.AddUint32(&ef, 1) == 1 {
err = err1
}
Expand Down
6 changes: 3 additions & 3 deletions worker/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func (w *Chain) Bind(workers ...queue.Worker) *Chain {

// Do process the item.
// Each worker in chain will be called for processing. Chain will stop processing on first failed worker.
func (w Chain) Do(x interface{}) (err error) {
for i := 0; i < len(w); i++ {
if err = w[i].Do(x); err != nil {
func (w *Chain) Do(x any) (err error) {
for i := 0; i < len(*w); i++ {
if err = (*w)[i].Do(x); err != nil {
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion worker/transit.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TransitTo(queue queue.Interface) *Transit {
return &w
}

func (w Transit) Do(x interface{}) error {
func (w Transit) Do(x any) error {
if w.queue == nil {
return queue.ErrNoQueue
}
Expand Down

0 comments on commit ef86a68

Please sign in to comment.