Skip to content

Commit

Permalink
Simplify batch queries (#218)
Browse files Browse the repository at this point in the history
1. Allow only one vector clock to be specified for each batch query (allows the server to be more simple/performant)
2. All endpoints are now batch endpoints, removed `batch` from all endpoint names
3. Remove a bunch of nesting from the protobufs. Note that a `repeated` field cannot be placed inside a `oneof` field, so I decided to remove the `oneof filter` as the alternative is multiple layers of nesting.

This and the next PR are fairly disruptive changes, heads up @mkysel. I'll take care of the server-side code changes, let me know if you'd like me to fix up client changes.

xmtp/xmtpd#126
  • Loading branch information
richardhuaaa authored Oct 11, 2024
1 parent 995f059 commit 06e6a50
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions proto/xmtpv4/message_api/message_api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,22 @@ message MisbehaviorReport {
}

// Query for envelopes, shared by query and subscribe endpoints
// Either topics or originator_node_ids may be set, but not both
message EnvelopesQuery {
oneof filter {
// Client queries
bytes topic = 1;
// Node queries
uint32 originator_node_id = 2;
}
// Client queries
repeated bytes topics = 1;
// Node queries
repeated uint32 originator_node_ids = 2;
VectorClock last_seen = 3;
}

// Batch subscribe to envelopes
message BatchSubscribeEnvelopesRequest {
// Single subscription request for envelopes
message SubscribeEnvelopesRequest {
EnvelopesQuery query = 1;
}
repeated SubscribeEnvelopesRequest requests = 1;
message SubscribeEnvelopesRequest {
EnvelopesQuery query = 1;
}

// Streamed response for batch subscribe - can be multiple envelopes at once
message BatchSubscribeEnvelopesResponse {
message SubscribeEnvelopesResponse {
repeated OriginatorEnvelope envelopes = 1;
}

Expand All @@ -116,12 +111,12 @@ message QueryEnvelopesResponse {
repeated OriginatorEnvelope envelopes = 1;
}

message PublishEnvelopeRequest {
PayerEnvelope payer_envelope = 1;
message PublishEnvelopesRequest {
repeated PayerEnvelope payer_envelopes = 1;
}

message PublishEnvelopeResponse {
OriginatorEnvelope originator_envelope = 1;
message PublishEnvelopesResponse {
repeated OriginatorEnvelope originator_envelopes = 1;
}

// Request to retrieve the XIDs for the given addresses
Expand All @@ -148,7 +143,7 @@ message GetInboxIdsResponse {
// Replication API
service ReplicationApi {
// Subscribe to envelopes
rpc BatchSubscribeEnvelopes(BatchSubscribeEnvelopesRequest) returns (stream BatchSubscribeEnvelopesResponse) {
rpc SubscribeEnvelopes(SubscribeEnvelopesRequest) returns (stream SubscribeEnvelopesResponse) {
option (google.api.http) = {
post: "/mls/v2/subscribe-envelopes"
body: "*"
Expand All @@ -164,12 +159,13 @@ service ReplicationApi {
}

// Publish envelope
rpc PublishEnvelope(PublishEnvelopeRequest) returns (PublishEnvelopeResponse) {
rpc PublishEnvelopes(PublishEnvelopesRequest) returns (PublishEnvelopesResponse) {
option (google.api.http) = {
post: "/mls/v2/publish-envelope"
post: "/mls/v2/publish-envelopes"
body: "*"
};
}

// Get inbox ids
rpc GetInboxIds(GetInboxIdsRequest) returns (GetInboxIdsResponse) {
option (google.api.http) = {
Expand Down

0 comments on commit 06e6a50

Please sign in to comment.