Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add event service #14686

Merged
merged 9 commits into from
Jan 23, 2023
Merged
Changes from 5 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
24 changes: 24 additions & 0 deletions core/event/manager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Package event provides a basic API for app modules to emit events.
package event

import (
"context"

"google.golang.org/protobuf/runtime/protoiface"
)

// Service represents an event service which can retrieve and set an event manager in a context.
// event.Service is a core API type that should be provided by the runtime module being used to
// build an app via depinject.
type Service interface {
// EmitProtoEvent emits events represented as a protobuf message (as described in ADR 032).
EmitProtoEvent(ctx context.Context, event protoiface.MessageV1) error

// EmitKVEvent emits an event based on an event and kv-pair attributes.
EmitKVEvent(ctx context.Context, eventType string, attrs ...KVEventAttribute) error
}

// KVEventAttribute is a kv-pair event attribute.
type KVEventAttribute struct {
Key, Value string
}