-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for protobuf service config
When sharing a schema via Buf, service config JSON files are not included. This commit adds an alternate way of defining service config: in the protobuf files, via a custom annotation. The service config protobuf schema is already defined in: https://buf.build/grpc/grpc/docs/main:grpc.service_config
- Loading branch information
Showing
11 changed files
with
308 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: v1 | ||
|
||
managed: | ||
enabled: true | ||
go_package_prefix: | ||
default: go.einride.tech/protoc-gen-go-grpc-service-config | ||
except: | ||
- buf.build/googleapis/googleapis | ||
|
||
plugins: | ||
- name: go-grpc-service-config | ||
out: internal/gen/proto | ||
opt: module=go.einride.tech/protoc-gen-go-grpc-service-config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Generated by buf. DO NOT EDIT. | ||
version: v1 | ||
deps: | ||
- remote: buf.build | ||
owner: cncf | ||
repository: xds | ||
commit: 0492166643854ea08814f4349286f9cb | ||
- remote: buf.build | ||
owner: envoyproxy | ||
repository: envoy | ||
commit: 14eefb0da6dc45b784fc05e55e66326d | ||
- remote: buf.build | ||
owner: envoyproxy | ||
repository: protoc-gen-validate | ||
commit: dc09a417d27241f7b069feae2cd74a0e | ||
- remote: buf.build | ||
owner: googleapis | ||
repository: googleapis | ||
commit: 86d30bdfc34044fb9339e1bd9673839b | ||
- remote: buf.build | ||
owner: grpc | ||
repository: grpc | ||
commit: 40b550c256324a8f85ba933e92479f95 | ||
- remote: buf.build | ||
owner: opencensus | ||
repository: opencensus | ||
commit: d1d7ccd1281e4f42ab7ce9a7d2b29e33 | ||
- remote: buf.build | ||
owner: opentelemetry | ||
repository: opentelemetry | ||
commit: 509848662be44e4d8aaf9189f6e6ab01 | ||
- remote: buf.build | ||
owner: prometheus | ||
repository: client-model | ||
commit: 1d56a02d481a412a83b3c4984eb90c2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version: v1 | ||
|
||
name: buf.build/einride/grpc-service-config | ||
|
||
deps: | ||
- buf.build/grpc/grpc | ||
|
||
lint: | ||
use: | ||
- DEFAULT | ||
except: | ||
- RPC_RESPONSE_STANDARD_NAME | ||
- RPC_REQUEST_RESPONSE_UNIQUE | ||
- ENUM_VALUE_PREFIX | ||
ignore: | ||
|
||
breaking: | ||
use: | ||
- PACKAGE | ||
ignore: | ||
26 changes: 26 additions & 0 deletions
26
einride/serviceconfig/example/v1/default_service_config.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
syntax = "proto3"; | ||
|
||
package einride.serviceconfig.example.v1; | ||
|
||
import "einride/serviceconfig/v1/annotations.proto"; | ||
|
||
option (einride.serviceconfig.v1.default_service_config) = { | ||
method_config: { | ||
name: {} | ||
timeout: { | ||
seconds: 10 | ||
} | ||
retry_policy: { | ||
initial_backoff: { | ||
nanos: 200000000 // 0.2s | ||
} | ||
max_backoff: { | ||
seconds: 60 | ||
} | ||
max_attempts: 5 | ||
backoff_multiplier: 2 | ||
retryable_status_codes: UNAVAILABLE | ||
retryable_status_codes: UNKNOWN | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
syntax = "proto3"; | ||
|
||
package einride.serviceconfig.v1; | ||
|
||
import "google/protobuf/descriptor.proto"; | ||
import "grpc/service_config/service_config.proto"; | ||
|
||
extend google.protobuf.FileOptions { | ||
// The `default_service_config` annotation provides default gRPC service | ||
// configuration for the services in the package. | ||
// | ||
// Magic number is the 28 most significant bits in the sha256sum of | ||
// `einride.serviceconfig.v1.default_service_config`. | ||
grpc.service_config.ServiceConfig default_service_config = 262421647; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
internal/gen/proto/einride/serviceconfig/example/v1/example_grpc_service_config.pb.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.