Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
/ cosmos-sdk Public archive
forked from cosmos/cosmos-sdk

Commit

Permalink
feat: simplify event service interface (cosmos#14859)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
Co-authored-by: marbar3778 <[email protected]>
  • Loading branch information
3 people authored and tsenart committed Apr 12, 2023
1 parent fea9947 commit 44bf888
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions core/event/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,33 @@ import (
// 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).
EventManager(context.Context) Manager
}

// Manager represents an event manager which can emit events.
type Manager interface {
// Emit emits events represented as a protobuf message (as described in ADR 032).
//
// Callers SHOULD assume that these events may be included in consensus. These events
// MUST be emitted deterministically and adding, removing or changing these events SHOULD
// be considered state-machine breaking.
EmitProtoEvent(ctx context.Context, event protoiface.MessageV1) error
Emit(ctx context.Context, event protoiface.MessageV1) error

// EmitKVEvent emits an event based on an event and kv-pair attributes.
// EmitKV emits an event based on an event and kv-pair attributes.
//
// These events will not be part of consensus and adding, removing or changing these events is
// not a state-machine breaking change.
EmitKVEvent(ctx context.Context, eventType string, attrs ...KVEventAttribute) error
EmitKV(ctx context.Context, eventType string, attrs ...Attribute) error

// EmitProtoEventNonConsensus emits events represented as a protobuf message (as described in ADR 032), without
// EmitNonConsensus emits events represented as a protobuf message (as described in ADR 032), without
// including it in blockchain consensus.
//
// These events will not be part of consensus and adding, removing or changing events is
// not a state-machine breaking change.
EmitProtoEventNonConsensus(ctx context.Context, event protoiface.MessageV1) error
EmitNonConsensus(ctx context.Context, event protoiface.MessageV1) error
}

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

0 comments on commit 44bf888

Please sign in to comment.