2021-09-23 11:05:51 +08:00
|
|
|
package event
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
type Consumer struct {
|
|
|
|
driver DriverInterface
|
|
|
|
}
|
|
|
|
|
2021-10-26 09:29:39 +08:00
|
|
|
func (c *Consumer) Receive(ctx context.Context) *event {
|
2021-09-23 11:05:51 +08:00
|
|
|
return c.driver.Get()
|
|
|
|
}
|
|
|
|
|
2021-10-26 09:29:39 +08:00
|
|
|
func (c *Consumer) NewEvent(name string) *event {
|
|
|
|
return c.driver.NewEvent(name)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Consumer) Recovery(e *event) {
|
|
|
|
c.driver.Recovery(e)
|
|
|
|
}
|
|
|
|
|
2021-09-23 11:05:51 +08:00
|
|
|
func NewConsumer(driver DriverInterface) ConsumerInterface {
|
|
|
|
return &Consumer{
|
|
|
|
driver: driver,
|
|
|
|
}
|
|
|
|
}
|