github.com/micro/go-micro/examples@v0.0.0-20210105173217-bf4ab679e18b/server/proto/example/example.micro.go (about)

     1  // Code generated by protoc-gen-micro. DO NOT EDIT.
     2  // source: github.com/micro/go-micro/examples/server/proto/example/example.proto
     3  
     4  /*
     5  Package go_micro_srv_example is a generated protocol buffer package.
     6  
     7  It is generated from these files:
     8  	github.com/micro/go-micro/examples/server/proto/example/example.proto
     9  
    10  It has these top-level messages:
    11  	Message
    12  	Request
    13  	Response
    14  	StreamingRequest
    15  	StreamingResponse
    16  	Ping
    17  	Pong
    18  */
    19  package go_micro_srv_example
    20  
    21  import proto "github.com/golang/protobuf/proto"
    22  import fmt "fmt"
    23  import math "math"
    24  
    25  import (
    26  	context "context"
    27  	client "github.com/micro/go-micro/v2/client"
    28  	server "github.com/micro/go-micro/v2/server"
    29  )
    30  
    31  // Reference imports to suppress errors if they are not otherwise used.
    32  var _ = proto.Marshal
    33  var _ = fmt.Errorf
    34  var _ = math.Inf
    35  
    36  // This is a compile-time assertion to ensure that this generated file
    37  // is compatible with the proto package it is being compiled against.
    38  // A compilation error at this line likely means your copy of the
    39  // proto package needs to be updated.
    40  const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
    41  
    42  // Reference imports to suppress errors if they are not otherwise used.
    43  var _ context.Context
    44  var _ client.Option
    45  var _ server.Option
    46  
    47  // Client API for Example service
    48  
    49  type ExampleService interface {
    50  	Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error)
    51  	Stream(ctx context.Context, in *StreamingRequest, opts ...client.CallOption) (Example_StreamService, error)
    52  	PingPong(ctx context.Context, opts ...client.CallOption) (Example_PingPongService, error)
    53  }
    54  
    55  type exampleService struct {
    56  	c           client.Client
    57  	serviceName string
    58  }
    59  
    60  func NewExampleService(serviceName string, c client.Client) ExampleService {
    61  	if c == nil {
    62  		c = client.NewClient()
    63  	}
    64  	if len(serviceName) == 0 {
    65  		serviceName = "go.micro.srv.example"
    66  	}
    67  	return &exampleService{
    68  		c:           c,
    69  		serviceName: serviceName,
    70  	}
    71  }
    72  
    73  func (c *exampleService) Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) {
    74  	req := c.c.NewRequest(c.serviceName, "Example.Call", in)
    75  	out := new(Response)
    76  	err := c.c.Call(ctx, req, out, opts...)
    77  	if err != nil {
    78  		return nil, err
    79  	}
    80  	return out, nil
    81  }
    82  
    83  func (c *exampleService) Stream(ctx context.Context, in *StreamingRequest, opts ...client.CallOption) (Example_StreamService, error) {
    84  	req := c.c.NewRequest(c.serviceName, "Example.Stream", &StreamingRequest{})
    85  	stream, err := c.c.Stream(ctx, req, opts...)
    86  	if err != nil {
    87  		return nil, err
    88  	}
    89  	if err := stream.Send(in); err != nil {
    90  		return nil, err
    91  	}
    92  	return &exampleStreamService{stream}, nil
    93  }
    94  
    95  type Example_StreamService interface {
    96  	SendMsg(interface{}) error
    97  	RecvMsg(interface{}) error
    98  	Close() error
    99  	Recv() (*StreamingResponse, error)
   100  }
   101  
   102  type exampleStreamService struct {
   103  	stream client.Stream
   104  }
   105  
   106  func (x *exampleStreamService) Close() error {
   107  	return x.stream.Close()
   108  }
   109  
   110  func (x *exampleStreamService) SendMsg(m interface{}) error {
   111  	return x.stream.Send(m)
   112  }
   113  
   114  func (x *exampleStreamService) RecvMsg(m interface{}) error {
   115  	return x.stream.Recv(m)
   116  }
   117  
   118  func (x *exampleStreamService) Recv() (*StreamingResponse, error) {
   119  	m := new(StreamingResponse)
   120  	err := x.stream.Recv(m)
   121  	if err != nil {
   122  		return nil, err
   123  	}
   124  	return m, nil
   125  }
   126  
   127  func (c *exampleService) PingPong(ctx context.Context, opts ...client.CallOption) (Example_PingPongService, error) {
   128  	req := c.c.NewRequest(c.serviceName, "Example.PingPong", &Ping{})
   129  	stream, err := c.c.Stream(ctx, req, opts...)
   130  	if err != nil {
   131  		return nil, err
   132  	}
   133  	return &examplePingPongService{stream}, nil
   134  }
   135  
   136  type Example_PingPongService interface {
   137  	SendMsg(interface{}) error
   138  	RecvMsg(interface{}) error
   139  	Close() error
   140  	Send(*Ping) error
   141  	Recv() (*Pong, error)
   142  }
   143  
   144  type examplePingPongService struct {
   145  	stream client.Stream
   146  }
   147  
   148  func (x *examplePingPongService) Close() error {
   149  	return x.stream.Close()
   150  }
   151  
   152  func (x *examplePingPongService) SendMsg(m interface{}) error {
   153  	return x.stream.Send(m)
   154  }
   155  
   156  func (x *examplePingPongService) RecvMsg(m interface{}) error {
   157  	return x.stream.Recv(m)
   158  }
   159  
   160  func (x *examplePingPongService) Send(m *Ping) error {
   161  	return x.stream.Send(m)
   162  }
   163  
   164  func (x *examplePingPongService) Recv() (*Pong, error) {
   165  	m := new(Pong)
   166  	err := x.stream.Recv(m)
   167  	if err != nil {
   168  		return nil, err
   169  	}
   170  	return m, nil
   171  }
   172  
   173  // Server API for Example service
   174  
   175  type ExampleHandler interface {
   176  	Call(context.Context, *Request, *Response) error
   177  	Stream(context.Context, *StreamingRequest, Example_StreamStream) error
   178  	PingPong(context.Context, Example_PingPongStream) error
   179  }
   180  
   181  func RegisterExampleHandler(s server.Server, hdlr ExampleHandler, opts ...server.HandlerOption) {
   182  	type example interface {
   183  		Call(ctx context.Context, in *Request, out *Response) error
   184  		Stream(ctx context.Context, stream server.Stream) error
   185  		PingPong(ctx context.Context, stream server.Stream) error
   186  	}
   187  	type Example struct {
   188  		example
   189  	}
   190  	h := &exampleHandler{hdlr}
   191  	s.Handle(s.NewHandler(&Example{h}, opts...))
   192  }
   193  
   194  type exampleHandler struct {
   195  	ExampleHandler
   196  }
   197  
   198  func (h *exampleHandler) Call(ctx context.Context, in *Request, out *Response) error {
   199  	return h.ExampleHandler.Call(ctx, in, out)
   200  }
   201  
   202  func (h *exampleHandler) Stream(ctx context.Context, stream server.Stream) error {
   203  	m := new(StreamingRequest)
   204  	if err := stream.Recv(m); err != nil {
   205  		return err
   206  	}
   207  	return h.ExampleHandler.Stream(ctx, m, &exampleStreamStream{stream})
   208  }
   209  
   210  type Example_StreamStream interface {
   211  	SendMsg(interface{}) error
   212  	RecvMsg(interface{}) error
   213  	Close() error
   214  	Send(*StreamingResponse) error
   215  }
   216  
   217  type exampleStreamStream struct {
   218  	stream server.Stream
   219  }
   220  
   221  func (x *exampleStreamStream) Close() error {
   222  	return x.stream.Close()
   223  }
   224  
   225  func (x *exampleStreamStream) SendMsg(m interface{}) error {
   226  	return x.stream.Send(m)
   227  }
   228  
   229  func (x *exampleStreamStream) RecvMsg(m interface{}) error {
   230  	return x.stream.Recv(m)
   231  }
   232  
   233  func (x *exampleStreamStream) Send(m *StreamingResponse) error {
   234  	return x.stream.Send(m)
   235  }
   236  
   237  func (h *exampleHandler) PingPong(ctx context.Context, stream server.Stream) error {
   238  	return h.ExampleHandler.PingPong(ctx, &examplePingPongStream{stream})
   239  }
   240  
   241  type Example_PingPongStream interface {
   242  	SendMsg(interface{}) error
   243  	RecvMsg(interface{}) error
   244  	Close() error
   245  	Send(*Pong) error
   246  	Recv() (*Ping, error)
   247  }
   248  
   249  type examplePingPongStream struct {
   250  	stream server.Stream
   251  }
   252  
   253  func (x *examplePingPongStream) Close() error {
   254  	return x.stream.Close()
   255  }
   256  
   257  func (x *examplePingPongStream) SendMsg(m interface{}) error {
   258  	return x.stream.Send(m)
   259  }
   260  
   261  func (x *examplePingPongStream) RecvMsg(m interface{}) error {
   262  	return x.stream.Recv(m)
   263  }
   264  
   265  func (x *examplePingPongStream) Send(m *Pong) error {
   266  	return x.stream.Send(m)
   267  }
   268  
   269  func (x *examplePingPongStream) Recv() (*Ping, error) {
   270  	m := new(Ping)
   271  	if err := x.stream.Recv(m); err != nil {
   272  		return nil, err
   273  	}
   274  	return m, nil
   275  }