mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-04 01:09:36 +02:00
directory: save IDP errors to databroker, put event handling in dedicated package (#2957)
This commit is contained in:
parent
2f328e7de0
commit
64ee7eca5c
13 changed files with 451 additions and 83 deletions
51
internal/events/events.go
Normal file
51
internal/events/events.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
// Package events contains a manager for dispatching and receiving arbitrary events.
|
||||
package events
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
"github.com/pomerium/pomerium/pkg/grpc/events"
|
||||
)
|
||||
|
||||
// An Event is any protobuf message that has a time and message.
|
||||
type Event interface {
|
||||
proto.Message
|
||||
GetTime() *timestamppb.Timestamp
|
||||
GetMessage() string
|
||||
}
|
||||
|
||||
// An EventSink receives events.
|
||||
type EventSink func(Event)
|
||||
|
||||
// An EventSinkHandle is a reference to a registered EventSink so that it can be unregistered.
|
||||
type EventSinkHandle string
|
||||
|
||||
// Dispatch dispatches an event to any event sinks.
|
||||
func Dispatch(evt Event) {
|
||||
defaultManager.Dispatch(evt)
|
||||
}
|
||||
|
||||
// Register registers a new sink to receive events.
|
||||
func Register(sink EventSink) EventSinkHandle {
|
||||
return defaultManager.Register(sink)
|
||||
}
|
||||
|
||||
// Unregister unregisters a sink so it will no longer receive events.
|
||||
func Unregister(sinkHandle EventSinkHandle) {
|
||||
defaultManager.Unregister(sinkHandle)
|
||||
}
|
||||
|
||||
type (
|
||||
// EnvoyConfigurationEvent re-exports events.EnvoyConfigurationEvent.
|
||||
EnvoyConfigurationEvent = events.EnvoyConfigurationEvent
|
||||
// IDPErrorEvent re-exports events.IDPErrorEvent.
|
||||
IDPErrorEvent = events.IDPErrorEvent
|
||||
)
|
||||
|
||||
// re-exported protobuf constants
|
||||
const (
|
||||
EnvoyConfigurationEvent_EVENT_DISCOVERY_REQUEST_ACK = events.EnvoyConfigurationEvent_EVENT_DISCOVERY_REQUEST_ACK // nolint
|
||||
EnvoyConfigurationEvent_EVENT_DISCOVERY_REQUEST_NACK = events.EnvoyConfigurationEvent_EVENT_DISCOVERY_REQUEST_NACK // nolint
|
||||
EnvoyConfigurationEvent_EVENT_DISCOVERY_RESPONSE = events.EnvoyConfigurationEvent_EVENT_DISCOVERY_RESPONSE // nolint
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue