mirror of
https://github.com/go-micro/go-micro.git
synced 2024-11-24 08:02:32 +02:00
update the example to message the naming of code generated protos
This commit is contained in:
parent
dee9cbb763
commit
f467902304
@ -28,17 +28,13 @@ func stream(i int) {
|
||||
return
|
||||
}
|
||||
for j := 0; j < i; j++ {
|
||||
rsp, err := stream.RecvR()
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println("err:", err)
|
||||
break
|
||||
}
|
||||
fmt.Println("Stream: rsp:", rsp.Count)
|
||||
}
|
||||
if stream.Error() != nil {
|
||||
fmt.Println("stream err:", err)
|
||||
return
|
||||
}
|
||||
if err := stream.Close(); err != nil {
|
||||
fmt.Println("stream close err:", err)
|
||||
}
|
||||
@ -51,22 +47,17 @@ func pingPong(i int) {
|
||||
return
|
||||
}
|
||||
for j := 0; j < i; j++ {
|
||||
if err := stream.SendR(&example.Ping{Stroke: int64(j)}); err != nil {
|
||||
if err := stream.Send(&example.Ping{Stroke: int64(j)}); err != nil {
|
||||
fmt.Println("err:", err)
|
||||
return
|
||||
}
|
||||
rsp, err := stream.RecvR()
|
||||
rsp, err := stream.Recv()
|
||||
if err != nil {
|
||||
fmt.Println("recv err", err)
|
||||
break
|
||||
}
|
||||
fmt.Printf("Sent ping %v got pong %v\n", j, rsp.Stroke)
|
||||
}
|
||||
if stream.Error() != nil {
|
||||
fmt.Println("stream err:", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := stream.Close(); err != nil {
|
||||
fmt.Println("stream close err:", err)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func (e *Example) Stream(ctx context.Context, req *example.StreamingRequest, str
|
||||
|
||||
for i := 0; i < int(req.Count); i++ {
|
||||
log.Infof("Responding: %d", i)
|
||||
if err := stream.SendR(&example.StreamingResponse{
|
||||
if err := stream.Send(&example.StreamingResponse{
|
||||
Count: int64(i),
|
||||
}); err != nil {
|
||||
return err
|
||||
@ -35,12 +35,12 @@ func (e *Example) Stream(ctx context.Context, req *example.StreamingRequest, str
|
||||
|
||||
func (e *Example) PingPong(ctx context.Context, stream example.Example_PingPongStream) error {
|
||||
for {
|
||||
req, err := stream.RecvR()
|
||||
req, err := stream.Recv()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("Got ping %v", req.Stroke)
|
||||
if err := stream.SendR(&example.Pong{Stroke: req.Stroke}); err != nil {
|
||||
if err := stream.Send(&example.Pong{Stroke: req.Stroke}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -161,17 +161,31 @@ func (c *exampleClient) Stream(ctx context.Context, in *StreamingRequest, opts .
|
||||
}
|
||||
|
||||
type Example_StreamClient interface {
|
||||
RecvR() (*StreamingResponse, error)
|
||||
client.Streamer
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Recv() (*StreamingResponse, error)
|
||||
}
|
||||
|
||||
type exampleStreamClient struct {
|
||||
client.Streamer
|
||||
stream client.Streamer
|
||||
}
|
||||
|
||||
func (x *exampleStreamClient) RecvR() (*StreamingResponse, error) {
|
||||
func (x *exampleStreamClient) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *exampleStreamClient) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *exampleStreamClient) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *exampleStreamClient) Recv() (*StreamingResponse, error) {
|
||||
m := new(StreamingResponse)
|
||||
err := x.Recv(m)
|
||||
err := x.stream.Recv(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -188,22 +202,36 @@ func (c *exampleClient) PingPong(ctx context.Context, opts ...client.CallOption)
|
||||
}
|
||||
|
||||
type Example_PingPongClient interface {
|
||||
SendR(*Ping) error
|
||||
RecvR() (*Pong, error)
|
||||
client.Streamer
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Send(*Ping) error
|
||||
Recv() (*Pong, error)
|
||||
}
|
||||
|
||||
type examplePingPongClient struct {
|
||||
client.Streamer
|
||||
stream client.Streamer
|
||||
}
|
||||
|
||||
func (x *examplePingPongClient) SendR(m *Ping) error {
|
||||
return x.Send(m)
|
||||
func (x *examplePingPongClient) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *examplePingPongClient) RecvR() (*Pong, error) {
|
||||
func (x *examplePingPongClient) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *examplePingPongClient) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *examplePingPongClient) Send(m *Ping) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *examplePingPongClient) Recv() (*Pong, error) {
|
||||
m := new(Pong)
|
||||
err := x.Recv(m)
|
||||
err := x.stream.Recv(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -239,16 +267,30 @@ func (h *Example) Stream(ctx context.Context, stream server.Streamer) error {
|
||||
}
|
||||
|
||||
type Example_StreamStream interface {
|
||||
SendR(*StreamingResponse) error
|
||||
server.Streamer
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Send(*StreamingResponse) error
|
||||
}
|
||||
|
||||
type exampleStreamStream struct {
|
||||
server.Streamer
|
||||
stream server.Streamer
|
||||
}
|
||||
|
||||
func (x *exampleStreamStream) SendR(m *StreamingResponse) error {
|
||||
return x.Streamer.Send(m)
|
||||
func (x *exampleStreamStream) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *exampleStreamStream) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *exampleStreamStream) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *exampleStreamStream) Send(m *StreamingResponse) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (h *Example) PingPong(ctx context.Context, stream server.Streamer) error {
|
||||
@ -256,22 +298,36 @@ func (h *Example) PingPong(ctx context.Context, stream server.Streamer) error {
|
||||
}
|
||||
|
||||
type Example_PingPongStream interface {
|
||||
SendR(*Pong) error
|
||||
RecvR() (*Ping, error)
|
||||
server.Streamer
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Send(*Pong) error
|
||||
Recv() (*Ping, error)
|
||||
}
|
||||
|
||||
type examplePingPongStream struct {
|
||||
server.Streamer
|
||||
stream server.Streamer
|
||||
}
|
||||
|
||||
func (x *examplePingPongStream) SendR(m *Pong) error {
|
||||
return x.Streamer.Send(m)
|
||||
func (x *examplePingPongStream) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *examplePingPongStream) RecvR() (*Ping, error) {
|
||||
func (x *examplePingPongStream) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *examplePingPongStream) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *examplePingPongStream) Send(m *Pong) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *examplePingPongStream) Recv() (*Ping, error) {
|
||||
m := new(Ping)
|
||||
if err := x.Streamer.Recv(m); err != nil {
|
||||
if err := x.stream.Recv(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
|
@ -1,12 +1,12 @@
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: github.com/micro/go-micro/proto/health/health.proto
|
||||
// source: micro/go-micro/server/proto/health/health.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package health is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
github.com/micro/go-micro/proto/health/health.proto
|
||||
micro/go-micro/server/proto/health/health.proto
|
||||
|
||||
It has these top-level messages:
|
||||
Request
|
||||
@ -15,24 +15,43 @@ It has these top-level messages:
|
||||
package health
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
type Request struct {
|
||||
}
|
||||
|
||||
func (m *Request) Reset() { *m = Request{} }
|
||||
func (m *Request) String() string { return proto.CompactTextString(m) }
|
||||
func (*Request) ProtoMessage() {}
|
||||
func (m *Request) Reset() { *m = Request{} }
|
||||
func (m *Request) String() string { return proto.CompactTextString(m) }
|
||||
func (*Request) ProtoMessage() {}
|
||||
func (*Request) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
|
||||
type Response struct {
|
||||
Status string `protobuf:"bytes,1,opt,name=status" json:"status,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Response) Reset() { *m = Response{} }
|
||||
func (m *Response) String() string { return proto.CompactTextString(m) }
|
||||
func (*Response) ProtoMessage() {}
|
||||
func (m *Response) Reset() { *m = Response{} }
|
||||
func (m *Response) String() string { return proto.CompactTextString(m) }
|
||||
func (*Response) ProtoMessage() {}
|
||||
func (*Response) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Request)(nil), "Request")
|
||||
proto.RegisterType((*Response)(nil), "Response")
|
||||
}
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 104 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xd2, 0xcf, 0xcd, 0x4c, 0x2e,
|
||||
0xca, 0xd7, 0x4f, 0xcf, 0xd7, 0x85, 0x30, 0x8a, 0x53, 0x8b, 0xca, 0x52, 0x8b, 0xf4, 0x0b, 0x8a,
|
||||
0xf2, 0x4b, 0xf2, 0xf5, 0x33, 0x52, 0x13, 0x73, 0x4a, 0x32, 0xa0, 0x94, 0x1e, 0x58, 0x4c, 0x89,
|
||||
0x93, 0x8b, 0x3d, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0x49, 0x8a, 0x8b, 0x23, 0x28, 0xb5,
|
||||
0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0x88, 0x8f, 0x8b, 0xad, 0xb8, 0x24, 0xb1, 0xa4, 0xb4, 0x58,
|
||||
0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x89, 0x0d, 0xac, 0xda, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff,
|
||||
0x2c, 0x7c, 0x5d, 0x9d, 0x60, 0x00, 0x00, 0x00,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user