You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/proto/private/pbservice/node.proto

128 lines
4.9 KiB

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
syntax = "proto3";
package hashicorp.consul.internal.service;
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.
2 years ago
import "private/pbcommon/common.proto";
import "private/pbservice/healthcheck.proto";
import "private/pbservice/service.proto";
// IndexedCheckServiceNodes is used to return multiple instances for a given service.
message IndexedCheckServiceNodes {
uint64 Index = 1;
repeated CheckServiceNode Nodes = 2;
}
// CheckServiceNode is used to provide the node, its service
// definition, as well as a HealthCheck that is associated.
message CheckServiceNode {
Node Node = 1;
NodeService Service = 2;
repeated HealthCheck Checks = 3;
}
// Node contains information about a node.
//
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.Node
// output=node.gen.go
// name=Structs
message Node {
// mog: func-to=NodeIDType func-from=string
string ID = 1;
string Node = 2;
string Partition = 8;
string PeerName = 9;
string Address = 3;
string Datacenter = 4;
map<string, string> TaggedAddresses = 5;
map<string, string> Meta = 6;
// mog: func-to=RaftIndexToStructs func-from=NewRaftIndexFromStructs
common.RaftIndex RaftIndex = 7;
// Locality identifies where the node is running.
// mog: func-to=LocalityToStructs func-from=LocalityFromStructs
common.Locality Locality = 10;
}
// NodeService is a service provided by a node
//
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.NodeService
// output=node.gen.go
// name=Structs
message NodeService {
// Kind is the kind of service this is. Different kinds of services may
// have differing validation, DNS behavior, etc. An empty kind will default
// to the Default kind. See ServiceKind for the full list of kinds.
// mog: func-to=structs.ServiceKind func-from=string
string Kind = 1;
string ID = 2;
string Service = 3;
repeated string Tags = 4;
string Address = 5;
// mog: func-to=MapStringServiceAddressToStructs func-from=NewMapStringServiceAddressFromStructs
map<string, ServiceAddress> TaggedAddresses = 15;
map<string, string> Meta = 6;
// mog: func-to=int func-from=int32
int32 Port = 7;
string SocketPath = 17;
// mog: func-to=WeightsPtrToStructs func-from=NewWeightsPtrFromStructs
Weights Weights = 8;
bool EnableTagOverride = 9;
// Proxy is the configuration set for Kind = connect-proxy. It is mandatory in
// that case and an error to be set for any other kind. This config is part of
// a proxy service definition and is distinct from but shares some fields with
// the Connect.Proxy which configures a managed proxy as part of the actual
// service's definition. This duplication is ugly but seemed better than the
// alternative which was to re-use the same struct fields for both cases even
// though the semantics are different and the non-shred fields make no sense
// in the other case. ProxyConfig may be a more natural name here, but it's
// confusing for the UX because one of the fields in ConnectProxyConfig is
// also called just "Config"
ConnectProxyConfig Proxy = 11;
// Connect are the Connect settings for a service. This is purposely NOT
// a pointer so that we never have to nil-check this.
ServiceConnect Connect = 12;
// LocallyRegisteredAsSidecar is private as it is only used by a local agent
// state to track if the service was registered from a nested sidecar_service
// block. We need to track that so we can know whether we need to deregister
// it automatically too if it's removed from the service definition or if the
// parent service is deregistered. Relying only on ID would cause us to
// deregister regular services if they happen to be registered using the same
// ID scheme as our sidecars do by default. We could use meta but that gets
// unpleasant because we can't use the consul- prefix from an agent (reserved
// for use internally but in practice that means within the state store or in
// responses only), and it leaks the detail publicly which people might rely
// on which is a bit unpleasant for something that is meant to be config-file
// syntax sugar. Note this is not translated to ServiceNode and friends and
// may not be set on a NodeService that isn't the one the agent registered and
// keeps in it's local state. We never want this rendered in JSON as it's
// internal only. Right now our agent endpoints return api structs which don't
// include it but this is a safety net incase we change that or there is
// somewhere this is used in API output.
bool LocallyRegisteredAsSidecar = 13;
// mog: func-to=EnterpriseMetaToStructs func-from=NewEnterpriseMetaFromStructs
common.EnterpriseMeta EnterpriseMeta = 16;
string PeerName = 18;
// mog: func-to=RaftIndexToStructs func-from=NewRaftIndexFromStructs
common.RaftIndex RaftIndex = 14;
// Locality identifies where the service is running.
// mog: func-to=LocalityToStructs func-from=LocalityFromStructs
common.Locality Locality = 19;
}