2023-03-13 21:56:44 +03:00
|
|
|
package kgo
|
|
|
|
|
|
|
|
import (
|
2024-05-05 16:20:05 +03:00
|
|
|
"context"
|
2023-03-13 21:56:44 +03:00
|
|
|
"sync"
|
|
|
|
|
|
|
|
"go.unistack.org/micro/v3/broker"
|
|
|
|
)
|
|
|
|
|
|
|
|
type event struct {
|
2024-12-19 13:21:32 +03:00
|
|
|
msg *broker.Message
|
|
|
|
err error
|
2024-12-19 13:36:55 +03:00
|
|
|
ctx context.Context
|
2024-12-19 13:21:32 +03:00
|
|
|
|
2023-03-13 21:56:44 +03:00
|
|
|
topic string
|
2024-12-19 13:21:32 +03:00
|
|
|
|
2023-03-13 21:56:44 +03:00
|
|
|
sync.RWMutex
|
|
|
|
ack bool
|
|
|
|
}
|
|
|
|
|
2024-05-05 16:20:05 +03:00
|
|
|
func (p *event) Context() context.Context {
|
|
|
|
return p.ctx
|
|
|
|
}
|
|
|
|
|
2023-03-13 21:56:44 +03:00
|
|
|
func (p *event) Topic() string {
|
|
|
|
return p.topic
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *event) Message() *broker.Message {
|
|
|
|
return p.msg
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *event) Ack() error {
|
|
|
|
p.ack = true
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *event) Error() error {
|
|
|
|
return p.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *event) SetError(err error) {
|
|
|
|
p.err = err
|
|
|
|
}
|
|
|
|
|
|
|
|
var eventPool = sync.Pool{
|
|
|
|
New: func() interface{} {
|
|
|
|
return &event{msg: &broker.Message{}}
|
|
|
|
},
|
|
|
|
}
|