112 lines
2.9 KiB
Protocol Buffer
112 lines
2.9 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
option csharp_namespace = "Svrnty.CQRS.Events.Grpc";
|
|
|
|
package svrnty.cqrs.events;
|
|
|
|
import "google/protobuf/timestamp.proto";
|
|
|
|
// Bidirectional streaming service for event subscriptions
|
|
service EventService {
|
|
// Subscribe to events with bidirectional streaming
|
|
// Client sends subscription requests, server sends events
|
|
rpc Subscribe(stream SubscriptionRequest) returns (stream EventMessage);
|
|
}
|
|
|
|
// Client-to-server messages
|
|
message SubscriptionRequest {
|
|
oneof request_type {
|
|
SubscribeCommand subscribe = 1;
|
|
UnsubscribeCommand unsubscribe = 2;
|
|
CatchUpCommand catch_up = 3;
|
|
AcknowledgeCommand acknowledge = 4;
|
|
NackCommand nack = 5;
|
|
}
|
|
}
|
|
|
|
message SubscribeCommand {
|
|
string subscription_id = 1;
|
|
string correlation_id = 2; // Workflow correlation ID
|
|
repeated string event_types = 3; // Empty = all types
|
|
repeated string terminal_event_types = 4; // For workflow completion
|
|
DeliveryMode delivery_mode = 5;
|
|
optional int32 timeout_seconds = 6;
|
|
optional string consumer_id = 7; // Phase 1.7: Optional consumer identifier
|
|
map<string, string> metadata = 8; // Phase 1.7: Consumer metadata (hostname, version, etc.)
|
|
}
|
|
|
|
message UnsubscribeCommand {
|
|
string subscription_id = 1;
|
|
}
|
|
|
|
message CatchUpCommand {
|
|
repeated string subscription_ids = 1;
|
|
}
|
|
|
|
message AcknowledgeCommand {
|
|
string subscription_id = 1;
|
|
string event_id = 2;
|
|
string consumer_id = 3;
|
|
}
|
|
|
|
message NackCommand {
|
|
string subscription_id = 1;
|
|
string event_id = 2;
|
|
string consumer_id = 3;
|
|
bool requeue = 4; // True = requeue for retry, False = dead letter
|
|
}
|
|
|
|
// Server-to-client messages
|
|
message EventMessage {
|
|
oneof message_type {
|
|
EventDelivery event = 1;
|
|
SubscriptionCompleted completed = 2;
|
|
ErrorMessage error = 3;
|
|
}
|
|
}
|
|
|
|
message EventDelivery {
|
|
string subscription_id = 1;
|
|
string correlation_id = 2;
|
|
string event_type = 3;
|
|
string event_id = 4;
|
|
int64 sequence = 5;
|
|
google.protobuf.Timestamp occurred_at = 6;
|
|
|
|
// Dynamic event payload will be a oneof with all registered event types
|
|
// This will be generated by the source generator
|
|
// For now, we use a placeholder to make the proto valid
|
|
oneof event_data {
|
|
// Placeholder - will be replaced/extended by source generator
|
|
PlaceholderEvent placeholder = 100;
|
|
// Generated event messages will be added here by source generator
|
|
// Example:
|
|
// UserInvitationSentEvent user_invitation_sent = 101;
|
|
// UserInvitationAcceptedEvent user_invitation_accepted = 102;
|
|
}
|
|
}
|
|
|
|
// Placeholder event type (will be removed when real events are generated)
|
|
message PlaceholderEvent {
|
|
string data = 1;
|
|
}
|
|
|
|
message SubscriptionCompleted {
|
|
string subscription_id = 1;
|
|
string reason = 2;
|
|
optional string terminal_event_type = 3;
|
|
}
|
|
|
|
message ErrorMessage {
|
|
string code = 1;
|
|
string message = 2;
|
|
optional string subscription_id = 3;
|
|
}
|
|
|
|
enum DeliveryMode {
|
|
DELIVERY_MODE_UNSPECIFIED = 0;
|
|
DELIVERY_MODE_IMMEDIATE = 1;
|
|
DELIVERY_MODE_BATCHED = 2;
|
|
DELIVERY_MODE_ON_RECONNECT = 3;
|
|
}
|