linkerd2-proxy-api 0.18.0

Linkerd Proxy API gRPC bindings and utilities
Documentation
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc             v6.30.2
// source: inbound.proto

package inbound

import (
	context "context"
	grpc "google.golang.org/grpc"
	codes "google.golang.org/grpc/codes"
	status "google.golang.org/grpc/status"
)

// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9

const (
	InboundServerPolicies_GetPort_FullMethodName   = "/io.linkerd.proxy.inbound.InboundServerPolicies/GetPort"
	InboundServerPolicies_WatchPort_FullMethodName = "/io.linkerd.proxy.inbound.InboundServerPolicies/WatchPort"
)

// InboundServerPoliciesClient is the client API for InboundServerPolicies service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// / An API exposed to the linkerd2-proxy to configure the inbound proxy with per-port configuration
// /
// / Proxies are expected to watch policies for each known port. As policies change, proxies update
// / their behavior for newly accepted connections.
// /
// / The unary `GetPort` endpoint is exposed as a convenience for clients to query policies for
// / diagnostic purposes.
type InboundServerPoliciesClient interface {
	// / Gets the inbound server policy for a given workload port.
	GetPort(ctx context.Context, in *PortSpec, opts ...grpc.CallOption) (*Server, error)
	// / Watches the inbound server policy for a given workload port.
	WatchPort(ctx context.Context, in *PortSpec, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Server], error)
}

type inboundServerPoliciesClient struct {
	cc grpc.ClientConnInterface
}

func NewInboundServerPoliciesClient(cc grpc.ClientConnInterface) InboundServerPoliciesClient {
	return &inboundServerPoliciesClient{cc}
}

func (c *inboundServerPoliciesClient) GetPort(ctx context.Context, in *PortSpec, opts ...grpc.CallOption) (*Server, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(Server)
	err := c.cc.Invoke(ctx, InboundServerPolicies_GetPort_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *inboundServerPoliciesClient) WatchPort(ctx context.Context, in *PortSpec, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Server], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &InboundServerPolicies_ServiceDesc.Streams[0], InboundServerPolicies_WatchPort_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[PortSpec, Server]{ClientStream: stream}
	if err := x.ClientStream.SendMsg(in); err != nil {
		return nil, err
	}
	if err := x.ClientStream.CloseSend(); err != nil {
		return nil, err
	}
	return x, nil
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type InboundServerPolicies_WatchPortClient = grpc.ServerStreamingClient[Server]

// InboundServerPoliciesServer is the server API for InboundServerPolicies service.
// All implementations must embed UnimplementedInboundServerPoliciesServer
// for forward compatibility.
//
// / An API exposed to the linkerd2-proxy to configure the inbound proxy with per-port configuration
// /
// / Proxies are expected to watch policies for each known port. As policies change, proxies update
// / their behavior for newly accepted connections.
// /
// / The unary `GetPort` endpoint is exposed as a convenience for clients to query policies for
// / diagnostic purposes.
type InboundServerPoliciesServer interface {
	// / Gets the inbound server policy for a given workload port.
	GetPort(context.Context, *PortSpec) (*Server, error)
	// / Watches the inbound server policy for a given workload port.
	WatchPort(*PortSpec, grpc.ServerStreamingServer[Server]) error
	mustEmbedUnimplementedInboundServerPoliciesServer()
}

// UnimplementedInboundServerPoliciesServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedInboundServerPoliciesServer struct{}

func (UnimplementedInboundServerPoliciesServer) GetPort(context.Context, *PortSpec) (*Server, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GetPort not implemented")
}
func (UnimplementedInboundServerPoliciesServer) WatchPort(*PortSpec, grpc.ServerStreamingServer[Server]) error {
	return status.Errorf(codes.Unimplemented, "method WatchPort not implemented")
}
func (UnimplementedInboundServerPoliciesServer) mustEmbedUnimplementedInboundServerPoliciesServer() {}
func (UnimplementedInboundServerPoliciesServer) testEmbeddedByValue()                               {}

// UnsafeInboundServerPoliciesServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to InboundServerPoliciesServer will
// result in compilation errors.
type UnsafeInboundServerPoliciesServer interface {
	mustEmbedUnimplementedInboundServerPoliciesServer()
}

func RegisterInboundServerPoliciesServer(s grpc.ServiceRegistrar, srv InboundServerPoliciesServer) {
	// If the following call pancis, it indicates UnimplementedInboundServerPoliciesServer was
	// embedded by pointer and is nil.  This will cause panics if an
	// unimplemented method is ever invoked, so we test this at initialization
	// time to prevent it from happening at runtime later due to I/O.
	if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
		t.testEmbeddedByValue()
	}
	s.RegisterService(&InboundServerPolicies_ServiceDesc, srv)
}

func _InboundServerPolicies_GetPort_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(PortSpec)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(InboundServerPoliciesServer).GetPort(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: InboundServerPolicies_GetPort_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(InboundServerPoliciesServer).GetPort(ctx, req.(*PortSpec))
	}
	return interceptor(ctx, in, info, handler)
}

func _InboundServerPolicies_WatchPort_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(PortSpec)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(InboundServerPoliciesServer).WatchPort(m, &grpc.GenericServerStream[PortSpec, Server]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type InboundServerPolicies_WatchPortServer = grpc.ServerStreamingServer[Server]

// InboundServerPolicies_ServiceDesc is the grpc.ServiceDesc for InboundServerPolicies service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var InboundServerPolicies_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "io.linkerd.proxy.inbound.InboundServerPolicies",
	HandlerType: (*InboundServerPoliciesServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "GetPort",
			Handler:    _InboundServerPolicies_GetPort_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "WatchPort",
			Handler:       _InboundServerPolicies_WatchPort_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "inbound.proto",
}