chore: change interface{} to any (#2818)

* chore: change interface{} to any

* chore: update goctl version to 1.5.0

* chore: update goctl deps
This commit is contained in:
Kevin Wan
2023-01-24 16:32:02 +08:00
committed by GitHub
parent 7e0ac77139
commit ae87114282
221 changed files with 1910 additions and 2207 deletions

View File

@@ -4,7 +4,7 @@ type (
// A Consumer interface represents a consumer that can consume string messages.
Consumer interface {
Consume(string) error
OnEvent(event interface{})
OnEvent(event any)
}
// ConsumerFactory defines the factory to generate consumers.

View File

@@ -31,7 +31,7 @@ type (
quit chan struct{}
listeners []Listener
eventLock sync.Mutex
eventChannels []chan interface{}
eventChannels []chan any
}
// A Listener interface represents a listener that can be notified with queue events.
@@ -77,7 +77,7 @@ func (q *Queue) AddListener(listener Listener) {
}
// Broadcast broadcasts message to all event channels.
func (q *Queue) Broadcast(message interface{}) {
func (q *Queue) Broadcast(message any) {
go func() {
q.eventLock.Lock()
defer q.eventLock.Unlock()
@@ -119,7 +119,7 @@ func (q *Queue) Stop() {
close(q.quit)
}
func (q *Queue) consume(eventChan chan interface{}) {
func (q *Queue) consume(eventChan chan any) {
var consumer Consumer
for {
@@ -216,7 +216,7 @@ func (q *Queue) resume() {
func (q *Queue) startConsumers(number int) {
for i := 0; i < number; i++ {
eventChan := make(chan interface{})
eventChan := make(chan any)
q.eventLock.Lock()
q.eventChannels = append(q.eventChannels, eventChan)
q.eventLock.Unlock()

View File

@@ -52,7 +52,7 @@ func (c *mockedConsumer) Consume(string) error {
return nil
}
func (c *mockedConsumer) OnEvent(interface{}) {
func (c *mockedConsumer) OnEvent(any) {
if atomic.AddInt32(&c.events, 1) <= consumers {
c.wait.Done()
}