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

*: use lite runtime #366

Merged
merged 8 commits into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ raft = "0.4"

[build-dependencies]
protobuf-build = "0.1"

# TODO: use patch instead if rust-lang/cargo#6762 is resolved.
[replace]
"protobuf-codegen:2.0.6" = { git = "https://github.com/busyjay/rust-protobuf.git", branch = "customize-lite-runtime-2.0" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nrc

can we use lite runtime in prost?

"protobuf:2.0.6" = { git = "https://github.com/busyjay/rust-protobuf.git", branch = "customize-lite-runtime-2.0" }
2 changes: 2 additions & 0 deletions generate_go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function collect() {
# Although eraftpb.proto is copying from raft-rs, however there is no
# official go code ship with the crate, so we need to generate it manually.
collect include/eraftpb.proto
collect include/rustproto.proto
cd proto
for file in `ls *.proto`
do
Expand All @@ -77,6 +78,7 @@ function gen() {
sed -i.bak -E 's/import fmt \"fmt\"//g' *.pb.go
sed -i.bak -E 's/import io \"io\"//g' *.pb.go
sed -i.bak -E 's/import math \"math\"//g' *.pb.go
sed -i.bak -E 's/import _ \".*rustproto\"//' *.pb.go
rm -f *.bak
goimports -w *.pb.go
cd ../../proto
Expand Down
47 changes: 47 additions & 0 deletions include/rustproto.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
syntax = "proto2";

import "google/protobuf/descriptor.proto";

// see https://github.com/gogo/protobuf/blob/master/gogoproto/gogo.proto
// for the original idea

package rustproto;

extend google.protobuf.FileOptions {
// When true, oneof field is generated public
optional bool expose_oneof_all = 17001;
// When true all fields are public, and not accessors generated
optional bool expose_fields_all = 17003;
// When false, `get_`, `set_`, `mut_` etc. accessors are not generated
optional bool generate_accessors_all = 17004;
// Use `bytes::Bytes` for `bytes` fields
optional bool carllerche_bytes_for_bytes_all = 17011;
// Use `bytes::Bytes` for `string` fields
optional bool carllerche_bytes_for_string_all = 17012;
// When true, will only generate codes that works with lite runtime.
optional bool lite_runtime_all = 17035;
}

extend google.protobuf.MessageOptions {
// When true, oneof field is generated public
optional bool expose_oneof = 17001;
// When true all fields are public, and not accessors generated
optional bool expose_fields = 17003;
// When false, `get_`, `set_`, `mut_` etc. accessors are not generated
optional bool generate_accessors = 17004;
// Use `bytes::Bytes` for `bytes` fields
optional bool carllerche_bytes_for_bytes = 17011;
// Use `bytes::Bytes` for `string` fields
optional bool carllerche_bytes_for_string = 17012;
}

extend google.protobuf.FieldOptions {
// When true all fields are public, and not accessors generated
optional bool expose_fields_field = 17003;
// When false, `get_`, `set_`, `mut_` etc. accessors are not generated
optional bool generate_accessors_field = 17004;
// Use `bytes::Bytes` for `bytes` fields
optional bool carllerche_bytes_for_bytes_field = 17011;
// Use `bytes::Bytes` for `string` fields
optional bool carllerche_bytes_for_string_field = 17012;
}
67 changes: 34 additions & 33 deletions pkg/coprocessor/coprocessor.pb.go

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