MCPcopy
hub / github.com/caddyserver/caddy / NewEvent

Function NewEvent

caddy.go:1135–1148  ·  view source on GitHub ↗

NewEvent creates a new event, but does not emit the event. To emit an event, call Emit() on the current instance of the caddyevents app instead. EXPERIMENTAL: Subject to change.

(ctx Context, name string, data map[string]any)

Source from the content-addressed store, hash-verified

1133//
1134// EXPERIMENTAL: Subject to change.
1135func NewEvent(ctx Context, name string, data map[string]any) (Event, error) {
1136 id, err := uuid.NewRandom()
1137 if err != nil {
1138 return Event{}, fmt.Errorf("generating new event ID: %v", err)
1139 }
1140 name = strings.ToLower(name)
1141 return Event{
1142 Data: data,
1143 id: id,
1144 ts: time.Now(),
1145 name: name,
1146 origin: ctx.Module(),
1147 }, nil
1148}
1149
1150func (e Event) ID() uuid.UUID { return e.id }
1151func (e Event) Timestamp() time.Time { return e.ts }

Callers 1

Calls 1

ModuleMethod · 0.80

Tested by 1