sample

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2025 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package sample provides sample grpc interface.

Index

Constants

View Source
const (
	Sample_Func1_FullMethodName = "/Sample/Func1"
	Sample_Func2_FullMethodName = "/Sample/Func2"
)

Variables

View Source
var File_grpc_sample_sample_proto protoreflect.FileDescriptor
View Source
var Sample_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "Sample",
	HandlerType: (*SampleServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Func1",
			Handler:    _Sample_Func1_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Func2",
			Handler:       _Sample_Func2_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "grpc/sample/sample.proto",
}

Sample_ServiceDesc is the grpc.ServiceDesc for Sample service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterSampleServer

func RegisterSampleServer(s grpc.ServiceRegistrar, srv SampleServer)

Types

type Reply

type Reply struct {
	Data1 int64  `protobuf:"varint,1,opt,name=data1,proto3" json:"data1,omitempty"`
	Data2 string `protobuf:"bytes,2,opt,name=data2,proto3" json:"data2,omitempty"`
	// contains filtered or unexported fields
}

func (*Reply) Descriptor deprecated

func (*Reply) Descriptor() ([]byte, []int)

Deprecated: Use Reply.ProtoReflect.Descriptor instead.

func (*Reply) GetData1

func (x *Reply) GetData1() int64

func (*Reply) GetData2

func (x *Reply) GetData2() string

func (*Reply) ProtoMessage

func (*Reply) ProtoMessage()

func (*Reply) ProtoReflect

func (x *Reply) ProtoReflect() protoreflect.Message

func (*Reply) Reset

func (x *Reply) Reset()

func (*Reply) String

func (x *Reply) String() string

type Request

type Request struct {
	Data1 int64  `protobuf:"varint,1,opt,name=data1,proto3" json:"data1,omitempty"`
	Data2 string `protobuf:"bytes,2,opt,name=data2,proto3" json:"data2,omitempty"`
	// contains filtered or unexported fields
}

func (*Request) Descriptor deprecated

func (*Request) Descriptor() ([]byte, []int)

Deprecated: Use Request.ProtoReflect.Descriptor instead.

func (*Request) GetData1

func (x *Request) GetData1() int64

func (*Request) GetData2

func (x *Request) GetData2() string

func (*Request) ProtoMessage

func (*Request) ProtoMessage()

func (*Request) ProtoReflect

func (x *Request) ProtoReflect() protoreflect.Message

func (*Request) Reset

func (x *Request) Reset()

func (*Request) String

func (x *Request) String() string

type SampleClient

type SampleClient interface {
	Func1(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Reply, error)
	Func2(ctx context.Context, opts ...grpc.CallOption) (Sample_Func2Client, error)
}

SampleClient is the client API for Sample 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.

func NewSampleClient

func NewSampleClient(cc grpc.ClientConnInterface) SampleClient

type SampleServer

type SampleServer interface {
	Func1(context.Context, *Request) (*Reply, error)
	Func2(Sample_Func2Server) error
	// contains filtered or unexported methods
}

SampleServer is the server API for Sample service. All implementations must embed UnimplementedSampleServer for forward compatibility

type Sample_Func2Client

type Sample_Func2Client interface {
	Send(*Request) error
	Recv() (*Reply, error)
	grpc.ClientStream
}

type Sample_Func2Server

type Sample_Func2Server interface {
	Send(*Reply) error
	Recv() (*Request, error)
	grpc.ServerStream
}

type Server

type Server struct {
	UnimplementedSampleServer
}

Server is struct that satisfies the implementServer interface and implements the function defined in protobuf IDL.

func (*Server) Func1

func (this *Server) Func1(context context.Context, request *Request) (*Reply, error)

Func1 is implementation of the function defined in protobuf IDL.

func (*Server) Func2

func (this *Server) Func2(stream Sample_Func2Server) error

Func2 is implementation of the function defined in protobuf IDL.

func (*Server) RegisterServer

func (this *Server) RegisterServer(grpcServer *grpc.Server)

RegisterServer is function to register in grpc server.

the function we need to call is Register{service name of proto file}Server

type UnimplementedSampleServer

type UnimplementedSampleServer struct {
}

UnimplementedSampleServer must be embedded to have forward compatible implementations.

func (UnimplementedSampleServer) Func1

func (UnimplementedSampleServer) Func2

type UnsafeSampleServer

type UnsafeSampleServer interface {
	// contains filtered or unexported methods
}

UnsafeSampleServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to SampleServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL