2023-01-17 21:34:37 +00:00
|
|
|
package logical
|
|
|
|
|
2023-01-20 18:18:23 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/hashicorp/go-uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ID is an alias to GetId() for CloudEvents compatibility.
|
2023-02-17 19:38:03 +00:00
|
|
|
func (x *EventReceived) ID() string {
|
|
|
|
return x.Event.GetId()
|
2023-01-20 18:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewEvent returns an event with a new, random EID.
|
|
|
|
func NewEvent() (*EventData, error) {
|
|
|
|
id, err := uuid.GenerateUUID()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &EventData{
|
|
|
|
Id: id,
|
|
|
|
}, nil
|
|
|
|
}
|
2023-01-17 21:34:37 +00:00
|
|
|
|
|
|
|
// EventType represents a topic, and is a wrapper around eventlogger.EventType.
|
|
|
|
type EventType string
|
|
|
|
|
|
|
|
// EventSender sends events to the common event bus.
|
|
|
|
type EventSender interface {
|
2023-01-20 18:18:23 +00:00
|
|
|
Send(ctx context.Context, eventType EventType, event *EventData) error
|
2023-01-17 21:34:37 +00:00
|
|
|
}
|