2021-03-14 15:02:07 +00:00
|
|
|
package encoding
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
)
|
|
|
|
|
2023-03-26 05:58:19 +00:00
|
|
|
func ServerDesc(name, tun, tunMulti string) grpc.ServiceDesc {
|
2021-03-14 15:02:07 +00:00
|
|
|
return grpc.ServiceDesc{
|
|
|
|
ServiceName: name,
|
|
|
|
HandlerType: (*GRPCServiceServer)(nil),
|
|
|
|
Methods: []grpc.MethodDesc{},
|
|
|
|
Streams: []grpc.StreamDesc{
|
|
|
|
{
|
2023-03-26 05:58:19 +00:00
|
|
|
StreamName: tun,
|
2021-03-14 15:02:07 +00:00
|
|
|
Handler: _GRPCService_Tun_Handler,
|
|
|
|
ServerStreams: true,
|
|
|
|
ClientStreams: true,
|
|
|
|
},
|
|
|
|
{
|
2023-03-26 05:58:19 +00:00
|
|
|
StreamName: tunMulti,
|
2021-03-14 15:02:07 +00:00
|
|
|
Handler: _GRPCService_TunMulti_Handler,
|
|
|
|
ServerStreams: true,
|
|
|
|
ClientStreams: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Metadata: "grpc.proto",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-26 05:58:19 +00:00
|
|
|
func (c *gRPCServiceClient) TunCustomName(ctx context.Context, name, tun string, opts ...grpc.CallOption) (GRPCService_TunClient, error) {
|
|
|
|
stream, err := c.cc.NewStream(ctx, &ServerDesc(name, tun, "").Streams[0], "/"+name+"/"+tun, opts...)
|
2021-03-14 15:02:07 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2024-08-22 14:18:36 +00:00
|
|
|
x := &grpc.GenericClientStream[Hunk, Hunk]{ClientStream: stream}
|
2021-03-14 15:02:07 +00:00
|
|
|
return x, nil
|
|
|
|
}
|
|
|
|
|
2023-03-26 05:58:19 +00:00
|
|
|
func (c *gRPCServiceClient) TunMultiCustomName(ctx context.Context, name, tunMulti string, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error) {
|
|
|
|
stream, err := c.cc.NewStream(ctx, &ServerDesc(name, "", tunMulti).Streams[1], "/"+name+"/"+tunMulti, opts...)
|
2021-03-14 15:02:07 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2024-08-22 14:18:36 +00:00
|
|
|
x := &grpc.GenericClientStream[MultiHunk, MultiHunk]{ClientStream: stream}
|
2021-03-14 15:02:07 +00:00
|
|
|
return x, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type GRPCServiceClientX interface {
|
2023-03-26 05:58:19 +00:00
|
|
|
TunCustomName(ctx context.Context, name, tun string, opts ...grpc.CallOption) (GRPCService_TunClient, error)
|
|
|
|
TunMultiCustomName(ctx context.Context, name, tunMulti string, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error)
|
2021-03-14 15:02:07 +00:00
|
|
|
Tun(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunClient, error)
|
|
|
|
TunMulti(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error)
|
|
|
|
}
|
|
|
|
|
2023-03-26 05:58:19 +00:00
|
|
|
func RegisterGRPCServiceServerX(s *grpc.Server, srv GRPCServiceServer, name, tun, tunMulti string) {
|
|
|
|
desc := ServerDesc(name, tun, tunMulti)
|
2021-03-14 15:02:07 +00:00
|
|
|
s.RegisterService(&desc, srv)
|
|
|
|
}
|