ehevent

package
v0.2.1-0...-bdf8d29 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Optional, standardized event structure + serialization format

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serialize

func Serialize(e Event) string

Types

type Allocators

type Allocators map[string]func() Event

type Event

type Event interface {
	MetaType() string
	Meta() *EventMeta
}

event has type (event's name) and metadata (common attributes shared by all events)

func Deserialize

func Deserialize(input string, allocators Allocators) (Event, error)

type EventMeta

type EventMeta struct {
	Timestamp            time.Time
	TimestampOfRecording time.Time
	// whose resource was acted upon?
	// - user changes her password => target=<self> and actor=<self> (though actor omitted then)
	// - when admin changes another users password => target=<someone> and actor=<admin>
	UserId string
	// "who done this"? most times user acts on her own resources, but sometimes
	// e.g. a super user can do stuff to another user's (the target) resources
	ImpersonatingUserId string
}

func Meta

func Meta(timestamp time.Time, userId string) EventMeta

func MetaSystemUser

func MetaSystemUser(timestamp time.Time) EventMeta

func MetaWithImpersonator

func MetaWithImpersonator(timestamp time.Time, userId string, impersonatingUserId string) EventMeta

func (*EventMeta) ActingUserOrDefaultToTarget

func (m *EventMeta) ActingUserOrDefaultToTarget() string

returns "who acted on someones resource" (most times same as user id, but could be impersonator)

func (*EventMeta) Serialize

func (e *EventMeta) Serialize(payload Event) string

<time> <event> <targetUser> [<actingUser>] [<backdate>] <payload>

looks like: 2017-12-17T10:28:28.528Z account.Created 2 {"Id":"bab11eda","FolderId":"root","Title":"Test SSH key"}

Jump to

Keyboard shortcuts

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