open-vault/sdk/logical/events.go
Hamid Ghaf 27bb03bbc0
adding copyright header (#19555)
* adding copyright header

* fix fmt and a test
2023-03-15 09:00:52 -07:00

35 lines
729 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package logical
import (
"context"
"github.com/hashicorp/go-uuid"
)
// ID is an alias to GetId() for CloudEvents compatibility.
func (x *EventReceived) ID() string {
return x.Event.GetId()
}
// 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
}
// 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 {
Send(ctx context.Context, eventType EventType, event *EventData) error
}