observer

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Notify

func Notify(observation Observation)

Notify sends a notification about the given Observation to the observers that attached to the relevant observable.

Types

type Event

type Event int

Event is an event

const (
	// Community Events
	// Auth Code Flow
	CEventAuthCodeSuccess Event = iota
	CEventAuthCodeFail

	// Device Flow
	CEventDeviceFlowSuccess
	CEventDeviceFlowSuccessWorkAround
	CEventDeviceFlowFail

	// Token Revocation
	CEventTokenRevocationFail
	CEventTokenRevocationRTOnly
	CEventTokenRevocationRTAndAT

	// ID Token Signature
	CEventIDTokenSignatureValid
	CEventIDTokenSignatureInvalid

	// AT Signature
	CEventAccessTokenSignatureValid
	CEventAccessTokenSignatureInvalid

	// Refresh Token JWT
	CEventRefreshTokenIsAJWT
	CEventRefreshTokenIsNotAJWT
	// Access Token JWT
	CEventAccessTokenIsAJWT
	CEventAccessTokenIsNotAJWT

	// Other Events
	EventFeatureValueChanged
	EventMailVerified
)

Defines the different events

func CondEvent

func CondEvent(cond bool, a, b Event) Event

CondEvent returns one of two Events depending on the passed condition

type Observation

type Observation struct {
	EventType  Event
	Identifier string
	Value      interface{}
}

Observation holds the Event of an observation, a related identifier string, and a value

type Observer

type Observer struct {
	// contains filtered or unexported fields
}

Observer is an struct that observers one or multiple Events.

func NewAttachedAndObservingObserver

func NewAttachedAndObservingObserver(spec Spec) *Observer

NewAttachedAndObservingObserver creates a new Observer, attaches, and starts observing.

func NewAttachedAndObservingTrueFalseObserver

func NewAttachedAndObservingTrueFalseObserver(spec TrueFalseObserverSpec) *Observer

NewAttachedAndObservingTrueFalseObserver creates a new TrueFalseObserver, attaches, and starts observing.

func NewObserver

func NewObserver(spec Spec) *Observer

NewObserver creates a new Observer

func NewTrueFalseObserver

func NewTrueFalseObserver(spec TrueFalseObserverSpec) *Observer

NewTrueFalseObserver creates a new Observer. This observer will only listen to two events which are considered as true and false. On an observation this value is passed to the trueFalseObserverCallback.

func (*Observer) AttachAndObserve

func (obs *Observer) AttachAndObserve()

AttachAndObserve attaches to the relevant observables and starts observing.

type Spec

type Spec struct {
	EventTypes []Event
	Action     callback
}

Spec describes an Observer

type TrueFalseObserverSpec

type TrueFalseObserverSpec struct {
	TrueEvent  Event
	FalseEvent Event
	Action     trueFalseObserverCallback
}

TrueFalseObserverSpec describes an TrueFalseObserver

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL