package grpc

import (
	"context"

	"google.golang.org/grpc"
	"google.golang.org/grpc/metadata"
)

type serverStream struct {
	originalStream grpc.ServerStream
	ctx            context.Context // nolint:containedctx
}

func newgRPCServerStream(ctx context.Context, originalStream grpc.ServerStream) grpc.ServerStream {
	return &serverStream{
		originalStream: originalStream,
		ctx:            ctx,
	}
}

func (ss *serverStream) SetHeader(md metadata.MD) error {
	return ss.originalStream.SendHeader(md)
}

func (ss *serverStream) SendHeader(md metadata.MD) error {
	return ss.originalStream.SendHeader(md)
}

func (ss *serverStream) SetTrailer(md metadata.MD) {
	ss.originalStream.SetTrailer(md)
}

func (ss *serverStream) Context() context.Context {
	return ss.ctx
}

func (ss *serverStream) SendMsg(m any) error {
	return ss.originalStream.SendMsg(m)
}

func (ss *serverStream) RecvMsg(m any) error {
	return ss.originalStream.RecvMsg(m)
}