1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-18 08:26:38 +02:00
go-micro/cmd/protoc-gen-micro/examples/greeter/greeter.pb.micro.go
2024-07-07 18:40:15 +01:00

180 lines
4.1 KiB
Go

// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: greeter.proto
package greeter
import (
fmt "fmt"
_ "google.golang.org/genproto/googleapis/api/annotations"
proto "google.golang.org/protobuf/proto"
math "math"
)
import (
context "context"
client "go-micro.dev/v5/client"
server "go-micro.dev/v5/server"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ client.Option
var _ server.Option
// Client API for Greeter service
type GreeterService interface {
Hello(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error)
Stream(ctx context.Context, opts ...client.CallOption) (Greeter_StreamService, error)
}
type greeterService struct {
c client.Client
name string
}
func NewGreeterService(name string, c client.Client) GreeterService {
return &greeterService{
c: c,
name: name,
}
}
func (c *greeterService) Hello(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) {
req := c.c.NewRequest(c.name, "Greeter.Hello", in)
out := new(Response)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *greeterService) Stream(ctx context.Context, opts ...client.CallOption) (Greeter_StreamService, error) {
req := c.c.NewRequest(c.name, "Greeter.Stream", &Request{})
stream, err := c.c.Stream(ctx, req, opts...)
if err != nil {
return nil, err
}
return &greeterServiceStream{stream}, nil
}
type Greeter_StreamService interface {
Context() context.Context
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Send(*Request) error
Recv() (*Response, error)
}
type greeterServiceStream struct {
stream client.Stream
}
func (x *greeterServiceStream) Close() error {
return x.stream.Close()
}
func (x *greeterServiceStream) Context() context.Context {
return x.stream.Context()
}
func (x *greeterServiceStream) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *greeterServiceStream) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *greeterServiceStream) Send(m *Request) error {
return x.stream.Send(m)
}
func (x *greeterServiceStream) Recv() (*Response, error) {
m := new(Response)
err := x.stream.Recv(m)
if err != nil {
return nil, err
}
return m, nil
}
// Server API for Greeter service
type GreeterHandler interface {
Hello(context.Context, *Request, *Response) error
Stream(context.Context, Greeter_StreamStream) error
}
func RegisterGreeterHandler(s server.Server, hdlr GreeterHandler, opts ...server.HandlerOption) error {
type greeter interface {
Hello(ctx context.Context, in *Request, out *Response) error
Stream(ctx context.Context, stream server.Stream) error
}
type Greeter struct {
greeter
}
h := &greeterHandler{hdlr}
return s.Handle(s.NewHandler(&Greeter{h}, opts...))
}
type greeterHandler struct {
GreeterHandler
}
func (h *greeterHandler) Hello(ctx context.Context, in *Request, out *Response) error {
return h.GreeterHandler.Hello(ctx, in, out)
}
func (h *greeterHandler) Stream(ctx context.Context, stream server.Stream) error {
return h.GreeterHandler.Stream(ctx, &greeterStreamStream{stream})
}
type Greeter_StreamStream interface {
Context() context.Context
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Send(*Response) error
Recv() (*Request, error)
}
type greeterStreamStream struct {
stream server.Stream
}
func (x *greeterStreamStream) Close() error {
return x.stream.Close()
}
func (x *greeterStreamStream) Context() context.Context {
return x.stream.Context()
}
func (x *greeterStreamStream) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *greeterStreamStream) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *greeterStreamStream) Send(m *Response) error {
return x.stream.Send(m)
}
func (x *greeterStreamStream) Recv() (*Request, error) {
m := new(Request)
if err := x.stream.Recv(m); err != nil {
return nil, err
}
return m, nil
}