open-consul/proto-public/pbserverdiscovery/serverdiscovery.proto

45 lines
1.4 KiB
Protocol Buffer
Raw Normal View History

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
// Package serverdiscovery provides a service on Consul servers to discover the set of servers
// currently able to handle incoming requests.
syntax = "proto3";
package hashicorp.consul.serverdiscovery;
Protobuf Refactoring for Multi-Module Cleanliness (#16302) Protobuf Refactoring for Multi-Module Cleanliness This commit includes the following: Moves all packages that were within proto/ to proto/private Rewrites imports to account for the packages being moved Adds in buf.work.yaml to enable buf workspaces Names the proto-public buf module so that we can override the Go package imports within proto/buf.yaml Bumps the buf version dependency to 1.14.0 (I was trying out the version to see if it would get around an issue - it didn't but it also doesn't break things and it seemed best to keep up with the toolchain changes) Why: In the future we will need to consume other protobuf dependencies such as the Google HTTP annotations for openapi generation or grpc-gateway usage. There were some recent changes to have our own ratelimiting annotations. The two combined were not working when I was trying to use them together (attempting to rebase another branch) Buf workspaces should be the solution to the problem Buf workspaces means that each module will have generated Go code that embeds proto file names relative to the proto dir and not the top level repo root. This resulted in proto file name conflicts in the Go global protobuf type registry. The solution to that was to add in a private/ directory into the path within the proto/ directory. That then required rewriting all the imports. Is this safe? AFAICT yes The gRPC wire protocol doesn't seem to care about the proto file names (although the Go grpc code does tack on the proto file name as Metadata in the ServiceDesc) Other than imports, there were no changes to any generated code as a result of this.
2023-02-17 21:14:46 +00:00
import "annotations/ratelimit/ratelimit.proto";
2023-01-04 16:07:02 +00:00
service ServerDiscoveryService {
// WatchServers will stream back sets of ready servers as they change such as
// when new servers are added or older ones removed. A ready server is one that
// should be considered ready for sending general RPC requests towards that would
// catalog queries, xDS proxy configurations and similar services.
2023-01-04 16:07:02 +00:00
rpc WatchServers(WatchServersRequest) returns (stream WatchServersResponse) {
option (hashicorp.consul.internal.ratelimit.spec) = {
operation_type: OPERATION_TYPE_READ,
operation_category: OPERATION_CATEGORY_SERVER_DISCOVERY
};
2023-01-04 16:07:02 +00:00
}
}
message WatchServersRequest {
// Wan being set to true will cause WAN addresses to be sent in the response
// instead of the LAN addresses which are the default
bool wan = 1;
}
message WatchServersResponse {
// Servers is the list of server address information.
repeated Server servers = 1;
}
message Server {
// id is the unique string identifying this server for all time.
string id = 1;
// address on the network of the server
string address = 2;
// the consul version of the server
string version = 3;
}