Skip to content

Commit

Permalink
*: use lite runtime (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
BusyJay committed Mar 22, 2019
1 parent fbcaeb1 commit a637188
Show file tree
Hide file tree
Showing 37 changed files with 1,509 additions and 12,124 deletions.
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" }
"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.

0 comments on commit a637188

Please sign in to comment.