Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,12 @@ is held as a `subjectid.SubjectIdentifier`, parsed and validated there.
### Register an event type

An event vocabulary (such as OpenID CAEP or RISC) implements the `Event`
interface for its payload and registers a decoder for its event-type URI,
customarily from an `init` function so a side-effect import wires the whole
vocabulary in. Registration is process-wide and permanent.
interface for its payload and registers a decoder for its event-type URI.
`RegisterEventType` is the only registration call — place it in the vocabulary
package's `init` function (`init` is *where* you register, not an alternative
to registering) so a single side-effect import wires the whole vocabulary in,
the same idiom as `database/sql` drivers. Registration is process-wide and
permanent.

```go
const sessionRevokedURI = "https://schemas.openid.net/secevent/caep/event-type/session-revoked"
Expand Down
12 changes: 9 additions & 3 deletions registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@ var eventRegistry = struct {

// RegisterEventType registers decode as the decoder for the given event-type
// URI, making LookupEventType (and the typed-access helpers built on it) able
// to turn that event's raw payload bytes into a typed Event. An event
// vocabulary calls this once per event type it defines, customarily from a
// package init function so a side-effect import wires the whole vocabulary in.
// to turn that event's raw payload bytes into a typed Event.
//
// This is the only registration mechanism. An event vocabulary makes one
// RegisterEventType call per event type it defines and places those calls in
// the vocabulary package's init function. The init function is not an
// alternative to RegisterEventType — it is simply where the call goes, so that
// a consumer can wire the whole vocabulary in with a single side-effect import
// (import _ "example.com/your-vocabulary"), the same idiom as database/sql
// drivers and image-format decoders.
//
// Registration is process-wide and permanent: there is no unregister. The uri
// must be the same string the event's EventTypeURI method returns.
Expand Down
Loading