Skip to content

Commit 2306fac

Browse files
committed
refactor: rename MessageID to message_seq_no in ordering.proto
This avoids the protobuf vs Go impedance mismatch for initialisms like message_id (in protobuf) which is compiled to MessageId in Go, which is not a recommended identifier in Go. To avoid this problem altogether, we simply change the field to message_seq_no, which becomes a valid Go identifier MessageSeqNo.
1 parent 02cdac4 commit 2306fac

File tree

6 files changed

+45
-40
lines changed

6 files changed

+45
-40
lines changed

.vscode/gorums.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ multicast
5454
naddr
5555
netrwhist
5656
obj's
57+
objc
5758
oneway
5859
Paxos
5960
Pedersen

encoding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (m *Message) GetMessageID() uint64 {
9898
if m == nil {
9999
return 0
100100
}
101-
return m.metadata.GetMessageID()
101+
return m.metadata.GetMessageSeqNo()
102102
}
103103

104104
func (m *Message) GetStatus() *status.Status {

ordering/gorums_metadata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
// This is used to pass client-specific metadata to the server via Gorums.
1414
// This method should be used by generated code only.
1515
func NewGorumsMetadata(ctx context.Context, msgID uint64, method string) *Metadata {
16-
gorumsMetadata := Metadata_builder{MessageID: msgID, Method: method}
16+
gorumsMetadata := Metadata_builder{MessageSeqNo: msgID, Method: method}
1717
md, _ := metadata.FromOutgoingContext(ctx)
1818
for k, vv := range md {
1919
for _, v := range vv {

ordering/ordering.pb.go

Lines changed: 29 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ordering/ordering.proto

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@ edition = "2023";
22

33
package ordering;
44
option go_package = "github.com/relab/gorums/ordering";
5-
65
option features.field_presence = IMPLICIT;
76

87
import "google/rpc/status.proto";
98

9+
// Gorums is the main service for Gorums' per-node stream communication.
1010
service Gorums {
1111
// NodeStream is a stream that connects a client to a Node.
1212
// The messages that are sent on the stream contain both Metadata
1313
// and an application-specific message.
14-
rpc NodeStream(stream Metadata) returns (stream Metadata);
14+
rpc NodeStream(stream Metadata) returns (stream Metadata);
1515
}
1616

1717
// Metadata is sent together with application-specific message types,
1818
// and contains information necessary for Gorums to handle the messages.
1919
message Metadata {
20-
uint64 MessageID = 1;
21-
string Method = 2;
22-
google.rpc.Status Status = 3;
23-
// per message client-generated metadata
24-
repeated MetadataEntry Entry = 4;
20+
uint64 message_seq_no = 1; // sequence number for this message
21+
string method = 2; // method name to invoke on the server
22+
google.rpc.Status status = 3; // status of an invocation (for responses)
23+
repeated MetadataEntry entry = 4; // per message client-generated metadata
2524
}
2625

26+
// MetadataEntry is a key-value pair for Metadata entries.
2727
message MetadataEntry {
28-
string Key = 1;
29-
string Value = 2;
28+
string key = 1;
29+
string value = 2;
3030
}

ordering/ordering_grpc.pb.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)