Skip to content

Commit

Permalink
Patch google/protobuf/descriptor.proto and dev/restate/ext.proto
Browse files Browse the repository at this point in the history
The TS SDK seems to send incorrect file descriptors for google/protobuf/descriptor.proto
and dev/restate/ext.proto. This commit patches these files on the server as a temporary
solution until we remove the need for shipping Protobuf file descriptors.

This fixes #1262.
  • Loading branch information
tillrohrmann committed Mar 5, 2024
1 parent 7c9855e commit 1d34bee
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/service-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ protocol = []
[dependencies]
restate-base64-util = { workspace = true, optional = true }
restate-errors = { workspace = true, optional = true }
# Temporary dependency which can be removed once we need no longer to patch file descriptors
restate-pb = { workspace = true }
restate-schema-api = { workspace = true, optional = true, features = ["deployment"] }
restate-service-client = { workspace = true, optional = true }
restate-types = { workspace = true, optional = true }
Expand Down
27 changes: 27 additions & 0 deletions crates/service-protocol/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,33 @@ fn patch_built_in_descriptors(mut files: Bytes) -> Result<Bytes, ServiceDiscover
*file = prost_reflect_types::FileDescriptorProto::decode(&*file_desc)
.expect("This deserialization should not fail!");
}

// Temporary fix to make the TS SDK work with grpc service reflection. It seems that the
// TS SDK is not able to send the proper FileDescriptors for the below files. This can be
// removed once we no longer rely on receiving gRPC file descriptors from the SDK.
if file.name() == "google/protobuf/descriptor.proto" {
// Let's take the descriptor we need from the DescriptorPool::global()
let file_desc = DescriptorPool::global()
.get_file_by_name("google/protobuf/descriptor.proto")
.expect("The global descriptor pool must contain descriptor.proto")
.encode_to_vec();

// Let's apply it
*file = prost_reflect_types::FileDescriptorProto::decode(&*file_desc)
.expect("This deserialization should not fail!");
}

if file.name() == "dev/restate/ext.proto" {
// Let's take the descriptor we need from the restate_pb descriptor pool
let file_desc = restate_pb::DESCRIPTOR_POOL
.get_file_by_name("dev/restate/ext.proto")
.expect("The restate_pb descriptor pool must contain ext.proto")
.encode_to_vec();

// Let's apply it
*file = prost_reflect_types::FileDescriptorProto::decode(&*file_desc)
.expect("This deserialization should not fail!");
}
}

Ok(Bytes::from(files.encode_to_vec()))
Expand Down

0 comments on commit 1d34bee

Please sign in to comment.