Skip to content

Commit df4a06b

Browse files
[raft/proto] Add generate raft protos logic (#1909)
1 parent 8579c7e commit df4a06b

20 files changed

Lines changed: 6913 additions & 1 deletion

‎.github/workflows/ci.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ jobs:
3636
git diff --exit-code -- '*.gen.go' # Should not have been changed by previous steps
3737
make apis
3838
git diff --exit-code -- '*.gen.go' # Should not have been changed my make apis
39+
- name: Ensure files don't change when generating protos
40+
run: |
41+
git diff --exit-code -- '*.pb.go' # Should not have been changed by previous steps
42+
make protos
43+
git diff --exit-code -- '*.pb.go' # Should not have been changed by make protos
3944
- name: Ensure files don't change when running hygiene
4045
run: |
4146
git diff --exit-code

‎Makefile‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,27 @@ dummy_oauth_api: openapi-to-go-server
133133
--api_folder /resources/output/api
134134
# ---
135135

136+
# --- Targets to autogenerate Go code for Protocol Buffers definitions ---
137+
PROTO_FILES := $(shell find interfaces/raft -name '*.proto')
138+
139+
.PHONY: protos
140+
protos: protoc-go
141+
docker container run -u "$(USER_GROUP)" --rm \
142+
-v "$(CURDIR):/dss" -w /dss \
143+
interuss/dss-protoc-go \
144+
-I interfaces/raft \
145+
--go_out=. --go_opt=module=github.com/interuss/dss \
146+
$(PROTO_FILES)
147+
148+
# The Go version and protoc-gen-go must match the go and google.golang.org/protobuf versions in go.mod.
149+
# TODO: pass the Go version the same way to the other Docker images building Go code to keep them in sync with go.mod.
150+
protoc-go:
151+
docker image build \
152+
--build-arg GO_VERSION=$$(go list -m -f '{{.GoVersion}}') \
153+
--build-arg PROTOC_GEN_GO_VERSION=$$(go list -m -f '{{.Version}}' google.golang.org/protobuf) \
154+
-t interuss/dss-protoc-go ./build/protoc-go
155+
# ---
156+
136157
.PHONY: check-dss
137158
check-dss: evaluate-tanka test-go-units test-go-units-crdb test-e2e
138159

‎build/protoc-go/Dockerfile‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Set by `make protoc-go` to the Go version in go.mod.
2+
ARG GO_VERSION=1.27.1
3+
FROM golang:${GO_VERSION}
4+
5+
ARG PROTOC_VERSION=36.2
6+
# Set by `make protoc-go` to the google.golang.org/protobuf version in go.mod.
7+
ARG PROTOC_GEN_GO_VERSION
8+
9+
RUN apt-get update \
10+
&& apt-get install -y --no-install-recommends unzip \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
RUN case "$(uname -m)" in \
14+
x86_64) arch=x86_64 ;; \
15+
aarch64|arm64) arch=aarch_64 ;; \
16+
*) echo "Unsupported architecture: $(uname -m)" && exit 1 ;; \
17+
esac \
18+
&& curl -sSfL -o /tmp/protoc.zip \
19+
"https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${arch}.zip" \
20+
&& unzip -q /tmp/protoc.zip -d /usr/local bin/protoc 'include/*' \
21+
&& rm /tmp/protoc.zip
22+
23+
RUN GOBIN=/usr/local/bin go install google.golang.org/protobuf/cmd/protoc-gen-go@${PROTOC_GEN_GO_VERSION}
24+
25+
ENTRYPOINT ["protoc"]

‎interfaces/raft/aux_/aux_.proto‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,11 @@ message RecordHeartbeat {
2020
optional google.protobuf.Timestamp next_heartbeat_expected_before = 4;
2121
string reporter = 5;
2222
}
23+
24+
message Payload {
25+
oneof payload {
26+
SaveOwnMetadata save_own_metadata = 1;
27+
GetDSSMetadata get_dss_metadata = 2;
28+
RecordHeartbeat record_heartbeat = 3;
29+
}
30+
}

‎interfaces/raft/proposal.proto‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
syntax = "proto3";
2+
3+
package dss.raftstore.consensus;
4+
5+
import "google/protobuf/timestamp.proto";
6+
import "aux_/aux_.proto";
7+
import "rid/payload.proto";
8+
import "scd/payload.proto";
9+
10+
option go_package = "github.com/interuss/dss/pkg/pb/raftpb";
11+
12+
message Proposal {
13+
bytes id = 1;
14+
uint64 node_id = 2;
15+
google.protobuf.Timestamp timestamp = 3;
16+
17+
oneof payload {
18+
aux.Payload aux_payload = 4;
19+
rid.Payload rid_payload = 5;
20+
scd.Payload scd_payload = 6;
21+
}
22+
}

‎interfaces/raft/rid/payload.proto‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
syntax = "proto3";
2+
3+
package rid;
4+
5+
import "rid/isa.proto";
6+
import "rid/subscriptions.proto";
7+
8+
option go_package = "github.com/interuss/dss/pkg/pb/ridpb";
9+
10+
message Payload {
11+
oneof payload {
12+
// ISA operations
13+
CreateIdentificationServiceAreaOperation create_identification_service_area_operation = 20;
14+
UpdateIdentificationServiceAreaOperation update_identification_service_area_operation = 21;
15+
DeleteIdentificationServiceAreaOperation delete_identification_service_area_operation = 22;
16+
17+
// ISA repository requests
18+
GetISARepoCall get_isa_repo_call = 40;
19+
InsertISARepoCall insert_isa_repo_call = 41;
20+
UpdateISARepoCall update_isa_repo_call = 42;
21+
DeleteISARepoCall delete_isa_repo_call = 43;
22+
SearchISAsRepoCall search_isas_repo_call = 44;
23+
CountISAsRepoCall count_isas_repo_call = 45;
24+
25+
// Subscription operations
26+
CreateSubscriptionOperation create_subscription_operation = 60;
27+
UpdateSubscriptionOperation update_subscription_operation = 61;
28+
DeleteSubscriptionOperation delete_subscription_operation = 62;
29+
30+
// Subscription repository requests
31+
GetSubscriptionRepoCall get_subscription_repo_call = 80;
32+
InsertSubscriptionRepoCall insert_subscription_repo_call = 81;
33+
UpdateSubscriptionRepoCall update_subscription_repo_call = 82;
34+
DeleteSubscriptionRepoCall delete_subscription_repo_call = 83;
35+
SearchSubscriptionsRepoCall search_subscriptions_repo_call = 84;
36+
SearchSubscriptionsByOwnerRepoCall search_subscriptions_by_owner_repo_call = 85;
37+
UpdateNotificationIdxsInCellsRepoCall update_notification_idxs_in_cells_repo_call = 86;
38+
MaxSubscriptionCountInCellsByOwnerRepoCall max_subscription_count_in_cells_by_owner_repo_call = 87;
39+
CountSubscriptionsRepoCall count_subscriptions_repo_call = 88;
40+
}
41+
}

‎interfaces/raft/scd/ovn.proto‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ syntax = "proto3";
22

33
package scd;
44

5-
option go_package = "github.com/interuss/dss/pkg/scd/scdpb";
5+
option go_package = "github.com/interuss/dss/pkg/pb/scdpb";
66

77
// OVN is an opaque version number. The OVNs generated by the DSS are carried in their raw form.
88
message OVN {

‎interfaces/raft/scd/payload.proto‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
syntax = "proto3";
2+
3+
package scd;
4+
5+
import "scd/availability.proto";
6+
import "scd/constraint.proto";
7+
import "scd/operational_intents.proto";
8+
import "scd/subscriptions.proto";
9+
10+
option go_package = "github.com/interuss/dss/pkg/pb/scdpb";
11+
12+
message Payload {
13+
oneof payload {
14+
// USS availability operations
15+
GetUssAvailabilityOperation get_uss_availability_operation = 20;
16+
SetUssAvailabilityOperation set_uss_availability_operation = 21;
17+
18+
// USS availability repository requests
19+
GetUssAvailabilityRepoCall get_uss_availability_repo_call = 40;
20+
UpsertUssAvailabilityRepoCall upsert_uss_availability_repo_call = 41;
21+
22+
// Constraint operations
23+
GetConstraintReferenceOperation get_constraint_reference_operation = 60;
24+
CreateConstraintReferenceOperation create_constraint_reference_operation = 61;
25+
UpdateConstraintReferenceOperation update_constraint_reference_operation = 62;
26+
DeleteConstraintReferenceOperation delete_constraint_reference_operation = 63;
27+
QueryConstraintReferencesOperation query_constraint_references_operation = 64;
28+
29+
// Constraint repository requests
30+
SearchConstraintsRepoCall search_constraints_repo_call = 80;
31+
GetConstraintRepoCall get_constraint_repo_call = 81;
32+
UpsertConstraintRepoCall upsert_constraint_repo_call = 82;
33+
DeleteConstraintRepoCall delete_constraint_repo_call = 83;
34+
CountConstraintsRepoCall count_constraints_repo_call = 84;
35+
36+
// Operational intent operations
37+
GetOperationalIntentReferenceOperation get_operational_intent_reference_operation = 100;
38+
CreateOperationalIntentReferenceOperation create_operational_intent_reference_operation = 101;
39+
UpdateOperationalIntentReferenceOperation update_operational_intent_reference_operation = 102;
40+
DeleteOperationalIntentReferenceOperation delete_operational_intent_reference_operation = 103;
41+
QueryOperationalIntentReferencesOperation query_operational_intent_references_operation = 104;
42+
43+
// Operational intent repository requests
44+
GetOperationalIntentRepoCall get_operational_intent_repo_call = 120;
45+
DeleteOperationalIntentRepoCall delete_operational_intent_repo_call = 121;
46+
UpsertOperationalIntentRepoCall upsert_operational_intent_repo_call = 122;
47+
SearchOperationalIntentsRepoCall search_operational_intents_repo_call = 123;
48+
GetDependentOperationalIntentsRepoCall get_dependent_operational_intents_repo_call = 124;
49+
CountOperationalIntentsRepoCall count_operational_intents_repo_call = 125;
50+
51+
// Subscription operations
52+
GetSubscriptionOperation get_subscription_operation = 140;
53+
CreateSubscriptionOperation create_subscription_operation = 141;
54+
UpdateSubscriptionOperation update_subscription_operation = 142;
55+
DeleteSubscriptionOperation delete_subscription_operation = 143;
56+
QuerySubscriptionsOperation query_subscriptions_operation = 144;
57+
58+
// Subscription repository requests
59+
SearchSubscriptionsRepoCall search_subscriptions_repo_call = 160;
60+
GetSubscriptionRepoCall get_subscription_repo_call = 161;
61+
UpsertSubscriptionRepoCall upsert_subscription_repo_call = 162;
62+
DeleteSubscriptionRepoCall delete_subscription_repo_call = 163;
63+
IncrementNotificationIndicesForOperationalIntentsRepoCall increment_notification_indices_for_operational_intents_repo_call = 164;
64+
IncrementNotificationIndicesForConstraintsRepoCall increment_notification_indices_for_constraints_repo_call = 165;
65+
CountSubscriptionsRepoCall count_subscriptions_repo_call = 166;
66+
}
67+
}

0 commit comments

Comments
 (0)