// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.6.1
// - protoc             (unknown)
// source: push/v1/push.proto

package pushv1

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 (
	Push_SubscribePush_FullMethodName = "/galaxy.backend.push.v1.Push/SubscribePush"
)

// PushClient is the client API for Push 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.
//
// Push is the unidirectional control channel from backend to gateway.
//
// Gateway opens SubscribePush once at startup and keeps the stream open.
// Backend pushes two classes of events: ClientEvent (opaque payload that
// gateway signs and forwards to active client subscriptions) and
// SessionInvalidation (instructs gateway to close subscriptions and
// reject in-flight requests for the affected sessions).
//
// See backend/README.md §7 for the runtime contract.
type PushClient interface {
	SubscribePush(ctx context.Context, in *GatewaySubscribeRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[PushEvent], error)
}

type pushClient struct {
	cc grpc.ClientConnInterface
}

func NewPushClient(cc grpc.ClientConnInterface) PushClient {
	return &pushClient{cc}
}

func (c *pushClient) SubscribePush(ctx context.Context, in *GatewaySubscribeRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[PushEvent], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &Push_ServiceDesc.Streams[0], Push_SubscribePush_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[GatewaySubscribeRequest, PushEvent]{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 Push_SubscribePushClient = grpc.ServerStreamingClient[PushEvent]

// PushServer is the server API for Push service.
// All implementations must embed UnimplementedPushServer
// for forward compatibility.
//
// Push is the unidirectional control channel from backend to gateway.
//
// Gateway opens SubscribePush once at startup and keeps the stream open.
// Backend pushes two classes of events: ClientEvent (opaque payload that
// gateway signs and forwards to active client subscriptions) and
// SessionInvalidation (instructs gateway to close subscriptions and
// reject in-flight requests for the affected sessions).
//
// See backend/README.md §7 for the runtime contract.
type PushServer interface {
	SubscribePush(*GatewaySubscribeRequest, grpc.ServerStreamingServer[PushEvent]) error
	mustEmbedUnimplementedPushServer()
}

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

func (UnimplementedPushServer) SubscribePush(*GatewaySubscribeRequest, grpc.ServerStreamingServer[PushEvent]) error {
	return status.Error(codes.Unimplemented, "method SubscribePush not implemented")
}
func (UnimplementedPushServer) mustEmbedUnimplementedPushServer() {}
func (UnimplementedPushServer) testEmbeddedByValue()              {}

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

func RegisterPushServer(s grpc.ServiceRegistrar, srv PushServer) {
	// If the following call panics, it indicates UnimplementedPushServer 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(&Push_ServiceDesc, srv)
}

func _Push_SubscribePush_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(GatewaySubscribeRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(PushServer).SubscribePush(m, &grpc.GenericServerStream[GatewaySubscribeRequest, PushEvent]{ServerStream: stream})
}

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

// Push_ServiceDesc is the grpc.ServiceDesc for Push service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Push_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "galaxy.backend.push.v1.Push",
	HandlerType: (*PushServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "SubscribePush",
			Handler:       _Push_SubscribePush_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "push/v1/push.proto",
}
