consul/proto-public/pbserverdiscovery/serverdiscovery_cloning_grp...

59 lines
2.3 KiB
Go

// Code generated by protoc-gen-grpc-inmem. DO NOT EDIT.
package pbserverdiscovery
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 _ ServerDiscoveryServiceClient = CloningServerDiscoveryServiceClient{}
// IsCloningServerDiscoveryServiceClient is an interface that can be used to detect
// that a ServerDiscoveryServiceClient is using the in-memory transport and has already
// been wrapped with a with a CloningServerDiscoveryServiceClient.
type IsCloningServerDiscoveryServiceClient interface {
IsCloningServerDiscoveryServiceClient() bool
}
// CloningServerDiscoveryServiceClient implements the ServerDiscoveryServiceClient 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 CloningServerDiscoveryServiceClient struct {
ServerDiscoveryServiceClient
}
func NewCloningServerDiscoveryServiceClient(client ServerDiscoveryServiceClient) ServerDiscoveryServiceClient {
if cloner, ok := client.(IsCloningServerDiscoveryServiceClient); ok && cloner.IsCloningServerDiscoveryServiceClient() {
// prevent a double clone if the underlying client is already the cloning client.
return client
}
return CloningServerDiscoveryServiceClient{
ServerDiscoveryServiceClient: client,
}
}
// IsCloningServerDiscoveryServiceClient implements the IsCloningServerDiscoveryServiceClient interface. This
// is only used to detect wrapped clients that would be double cloning data and prevent that.
func (c CloningServerDiscoveryServiceClient) IsCloningServerDiscoveryServiceClient() bool {
return true
}
func (c CloningServerDiscoveryServiceClient) WatchServers(ctx context.Context, in *WatchServersRequest, opts ...grpc.CallOption) (ServerDiscoveryService_WatchServersClient, error) {
in = proto.Clone(in).(*WatchServersRequest)
st, err := c.ServerDiscoveryServiceClient.WatchServers(ctx, in)
if err != nil {
return nil, err
}
return newCloningStream[*WatchServersResponse](st), nil
}