// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc             (unknown)
// source: authzed/api/materialize/v0/watchpermissions.proto

package v0

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 (
	WatchPermissionsService_WatchPermissions_FullMethodName = "/authzed.api.materialize.v0.WatchPermissionsService/WatchPermissions"
)

// WatchPermissionsServiceClient is the client API for WatchPermissionsService 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.
type WatchPermissionsServiceClient interface {
	// WatchPermissions returns a stream of PermissionChange events for the given permissions.
	//
	// WatchPermissions is a long-running RPC, and will stream events until the client
	// closes the connection or the server terminates the stream. The consumer is responsible of
	// keeping track of the last seen revision and resuming the stream from that point in the event
	// of disconnection or client-side restarts.
	//
	// The API does not offer a sharding mechanism and thus there should only be one consumer per target system.
	// Implementing an active-active HA consumer setup over the same target system will require coordinating which
	// revisions have been consumed in order to prevent transitioning to an inconsistent state.
	//
	// Usage of WatchPermissions requires to be explicitly enabled on the service, including the permissions to be
	// watched. It requires more resources and is less performant than WatchPermissionsSets. It's usage
	// is only recommended when performing the set intersections of WatchPermissionSets in the client side is not viable
	// or there is a strict application requirement to use consume the computed permissions.
	WatchPermissions(ctx context.Context, in *WatchPermissionsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[WatchPermissionsResponse], error)
}

type watchPermissionsServiceClient struct {
	cc grpc.ClientConnInterface
}

func NewWatchPermissionsServiceClient(cc grpc.ClientConnInterface) WatchPermissionsServiceClient {
	return &watchPermissionsServiceClient{cc}
}

func (c *watchPermissionsServiceClient) WatchPermissions(ctx context.Context, in *WatchPermissionsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[WatchPermissionsResponse], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &WatchPermissionsService_ServiceDesc.Streams[0], WatchPermissionsService_WatchPermissions_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[WatchPermissionsRequest, WatchPermissionsResponse]{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 WatchPermissionsService_WatchPermissionsClient = grpc.ServerStreamingClient[WatchPermissionsResponse]

// WatchPermissionsServiceServer is the server API for WatchPermissionsService service.
// All implementations must embed UnimplementedWatchPermissionsServiceServer
// for forward compatibility.
type WatchPermissionsServiceServer interface {
	// WatchPermissions returns a stream of PermissionChange events for the given permissions.
	//
	// WatchPermissions is a long-running RPC, and will stream events until the client
	// closes the connection or the server terminates the stream. The consumer is responsible of
	// keeping track of the last seen revision and resuming the stream from that point in the event
	// of disconnection or client-side restarts.
	//
	// The API does not offer a sharding mechanism and thus there should only be one consumer per target system.
	// Implementing an active-active HA consumer setup over the same target system will require coordinating which
	// revisions have been consumed in order to prevent transitioning to an inconsistent state.
	//
	// Usage of WatchPermissions requires to be explicitly enabled on the service, including the permissions to be
	// watched. It requires more resources and is less performant than WatchPermissionsSets. It's usage
	// is only recommended when performing the set intersections of WatchPermissionSets in the client side is not viable
	// or there is a strict application requirement to use consume the computed permissions.
	WatchPermissions(*WatchPermissionsRequest, grpc.ServerStreamingServer[WatchPermissionsResponse]) error
	mustEmbedUnimplementedWatchPermissionsServiceServer()
}

// UnimplementedWatchPermissionsServiceServer 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 UnimplementedWatchPermissionsServiceServer struct{}

func (UnimplementedWatchPermissionsServiceServer) WatchPermissions(*WatchPermissionsRequest, grpc.ServerStreamingServer[WatchPermissionsResponse]) error {
	return status.Errorf(codes.Unimplemented, "method WatchPermissions not implemented")
}
func (UnimplementedWatchPermissionsServiceServer) mustEmbedUnimplementedWatchPermissionsServiceServer() {
}
func (UnimplementedWatchPermissionsServiceServer) testEmbeddedByValue() {}

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

func RegisterWatchPermissionsServiceServer(s grpc.ServiceRegistrar, srv WatchPermissionsServiceServer) {
	// If the following call pancis, it indicates UnimplementedWatchPermissionsServiceServer 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(&WatchPermissionsService_ServiceDesc, srv)
}

func _WatchPermissionsService_WatchPermissions_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(WatchPermissionsRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(WatchPermissionsServiceServer).WatchPermissions(m, &grpc.GenericServerStream[WatchPermissionsRequest, WatchPermissionsResponse]{ServerStream: stream})
}

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

// WatchPermissionsService_ServiceDesc is the grpc.ServiceDesc for WatchPermissionsService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var WatchPermissionsService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "authzed.api.materialize.v0.WatchPermissionsService",
	HandlerType: (*WatchPermissionsServiceServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "WatchPermissions",
			Handler:       _WatchPermissionsService_WatchPermissions_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "authzed/api/materialize/v0/watchpermissions.proto",
}
