consul/proto-public/pbdns/dns_cloning_grpc.pb.go
Matt Keeler 326c0ecfbe
In-Memory gRPC (#19942)
* Implement In-Process gRPC for use by controller caching/indexing

This replaces the pipe base listener implementation we were previously using. The new style CAN avoid cloning resources which our controller caching/indexing is taking advantage of to not duplicate resource objects in memory.

To maintain safety for controllers and for them to be able to modify data they get back from the cache and the resource service, the client they are presented in their runtime will be wrapped with an autogenerated client which clones request and response messages as they pass through the client.

Another sizable change in this PR is to consolidate how server specific gRPC services get registered and managed. Before this was in a bunch of different methods and it was difficult to track down how gRPC services were registered. Now its all in one place.

* Fix race in tests

* Ensure the resource service is registered to the multiplexed handler for forwarding from client agents

* Expose peer streaming on the internal handler
2024-01-12 11:54:07 -05:00

59 lines
1.9 KiB
Go

// Code generated by protoc-gen-grpc-inmem. DO NOT EDIT.
package pbdns
import (
"context"
grpc "google.golang.org/grpc"
"google.golang.org/protobuf/proto"
)
// compile-time check to ensure that the generator is implementing all
// of the grpc client interfaces methods.
var _ DNSServiceClient = CloningDNSServiceClient{}
// IsCloningDNSServiceClient is an interface that can be used to detect
// that a DNSServiceClient is using the in-memory transport and has already
// been wrapped with a with a CloningDNSServiceClient.
type IsCloningDNSServiceClient interface {
IsCloningDNSServiceClient() bool
}
// CloningDNSServiceClient implements the DNSServiceClient interface by wrapping
// another implementation and copying all protobuf messages that pass through the client.
// This is mainly useful to wrap the an in-process client to insulate users of that
// client from having to care about potential immutability of data they receive or having
// the server implementation mutate their internal memory.
type CloningDNSServiceClient struct {
DNSServiceClient
}
func NewCloningDNSServiceClient(client DNSServiceClient) DNSServiceClient {
if cloner, ok := client.(IsCloningDNSServiceClient); ok && cloner.IsCloningDNSServiceClient() {
// prevent a double clone if the underlying client is already the cloning client.
return client
}
return CloningDNSServiceClient{
DNSServiceClient: client,
}
}
// IsCloningDNSServiceClient implements the IsCloningDNSServiceClient interface. This
// is only used to detect wrapped clients that would be double cloning data and prevent that.
func (c CloningDNSServiceClient) IsCloningDNSServiceClient() bool {
return true
}
func (c CloningDNSServiceClient) Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) {
in = proto.Clone(in).(*QueryRequest)
out, err := c.DNSServiceClient.Query(ctx, in)
if err != nil {
return nil, err
}
return proto.Clone(out).(*QueryResponse), nil
}