mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-16 04:54:42 +00:00
Moving cruftier services that are only used for tests under a test repo
This commit is contained in:
0
test/template/.gitignore
vendored
Normal file
0
test/template/.gitignore
vendored
Normal file
3
test/template/Dockerfile
Normal file
3
test/template/Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
||||
FROM alpine
|
||||
ADD idiomatic /idiomatic
|
||||
ENTRYPOINT [ "/idiomatic" ]
|
||||
17
test/template/Makefile
Normal file
17
test/template/Makefile
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
GOPATH:=$(shell go env GOPATH)
|
||||
.PHONY: proto
|
||||
proto:
|
||||
protoc --proto_path=. --micro_out=. --go_out=:. proto/idiomatic.proto
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
go build -o idiomatic *.go
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
go test -v ./... -cover
|
||||
|
||||
.PHONY: docker
|
||||
docker:
|
||||
docker build . -t idiomatic:latest
|
||||
53
test/template/README.md
Normal file
53
test/template/README.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Template Service
|
||||
|
||||
This is an example of a service template
|
||||
|
||||
Generated with
|
||||
|
||||
```
|
||||
micro new template
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
- [Configuration](#configuration)
|
||||
- [Dependencies](#dependencies)
|
||||
- [Usage](#usage)
|
||||
|
||||
## Configuration
|
||||
|
||||
- Alias: template
|
||||
|
||||
## Dependencies
|
||||
|
||||
Micro services depend on service discovery. The default is multicast DNS, a zeroconf system.
|
||||
|
||||
In the event you need a resilient multi-host setup we recommend etcd.
|
||||
|
||||
```
|
||||
# install etcd
|
||||
brew install etcd
|
||||
|
||||
# run etcd
|
||||
etcd
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
A Makefile is included for convenience
|
||||
|
||||
Build the binary
|
||||
|
||||
```
|
||||
make build
|
||||
```
|
||||
|
||||
Run the service
|
||||
```
|
||||
./template
|
||||
```
|
||||
|
||||
Build a docker image
|
||||
```
|
||||
make docker
|
||||
```
|
||||
24
test/template/cmd/template/main.go
Normal file
24
test/template/cmd/template/main.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/micro/services/template/handler"
|
||||
|
||||
"github.com/micro/micro/v3/service"
|
||||
"github.com/micro/micro/v3/service/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create service
|
||||
srv := service.New(
|
||||
service.Name("idiomatic"),
|
||||
service.Version("latest"),
|
||||
)
|
||||
|
||||
// Register handler
|
||||
srv.Handle(new(handler.Idiomatic))
|
||||
|
||||
// Run service
|
||||
if err := srv.Run(); err != nil {
|
||||
logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
2
test/template/generate.go
Normal file
2
test/template/generate.go
Normal file
@@ -0,0 +1,2 @@
|
||||
package main
|
||||
//go:generate make proto
|
||||
48
test/template/handler/idiomatic.go
Normal file
48
test/template/handler/idiomatic.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/micro/micro/v3/service/logger"
|
||||
|
||||
idiomatic "github.com/micro/services/template/proto"
|
||||
)
|
||||
|
||||
type Idiomatic struct{}
|
||||
|
||||
// Call is a single request handler called via client.Call or the generated client code
|
||||
func (e *Idiomatic) Call(ctx context.Context, req *idiomatic.Request, rsp *idiomatic.Response) error {
|
||||
log.Info("Received Idiomatic.Call request")
|
||||
rsp.Msg = "Hello " + req.Name
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stream is a server side stream handler called via client.Stream or the generated client code
|
||||
func (e *Idiomatic) Stream(ctx context.Context, req *idiomatic.StreamingRequest, stream idiomatic.Idiomatic_StreamStream) error {
|
||||
log.Infof("Received Idiomatic.Stream request with count: %d", req.Count)
|
||||
|
||||
for i := 0; i < int(req.Count); i++ {
|
||||
log.Infof("Responding: %d", i)
|
||||
if err := stream.Send(&idiomatic.StreamingResponse{
|
||||
Count: int64(i),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// PingPong is a bidirectional stream handler called via client.Stream or the generated client code
|
||||
func (e *Idiomatic) PingPong(ctx context.Context, stream idiomatic.Idiomatic_PingPongStream) error {
|
||||
for {
|
||||
req, err := stream.Recv()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("Got ping %v", req.Stroke)
|
||||
if err := stream.Send(&idiomatic.Pong{Stroke: req.Stroke}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
327
test/template/proto/idiomatic.pb.go
Normal file
327
test/template/proto/idiomatic.pb.go
Normal file
@@ -0,0 +1,327 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: proto/idiomatic.proto
|
||||
|
||||
package idiomatic
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type Message struct {
|
||||
Say string `protobuf:"bytes,1,opt,name=say,proto3" json:"say,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Message) Reset() { *m = Message{} }
|
||||
func (m *Message) String() string { return proto.CompactTextString(m) }
|
||||
func (*Message) ProtoMessage() {}
|
||||
func (*Message) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_70718d389c4b1652, []int{0}
|
||||
}
|
||||
|
||||
func (m *Message) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Message.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Message.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Message) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Message.Merge(m, src)
|
||||
}
|
||||
func (m *Message) XXX_Size() int {
|
||||
return xxx_messageInfo_Message.Size(m)
|
||||
}
|
||||
func (m *Message) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Message.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Message proto.InternalMessageInfo
|
||||
|
||||
func (m *Message) GetSay() string {
|
||||
if m != nil {
|
||||
return m.Say
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Request) Reset() { *m = Request{} }
|
||||
func (m *Request) String() string { return proto.CompactTextString(m) }
|
||||
func (*Request) ProtoMessage() {}
|
||||
func (*Request) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_70718d389c4b1652, []int{1}
|
||||
}
|
||||
|
||||
func (m *Request) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Request.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Request.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Request) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Request.Merge(m, src)
|
||||
}
|
||||
func (m *Request) XXX_Size() int {
|
||||
return xxx_messageInfo_Request.Size(m)
|
||||
}
|
||||
func (m *Request) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Request.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Request proto.InternalMessageInfo
|
||||
|
||||
func (m *Request) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Response) Reset() { *m = Response{} }
|
||||
func (m *Response) String() string { return proto.CompactTextString(m) }
|
||||
func (*Response) ProtoMessage() {}
|
||||
func (*Response) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_70718d389c4b1652, []int{2}
|
||||
}
|
||||
|
||||
func (m *Response) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Response.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Response.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Response) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Response.Merge(m, src)
|
||||
}
|
||||
func (m *Response) XXX_Size() int {
|
||||
return xxx_messageInfo_Response.Size(m)
|
||||
}
|
||||
func (m *Response) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Response.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Response proto.InternalMessageInfo
|
||||
|
||||
func (m *Response) GetMsg() string {
|
||||
if m != nil {
|
||||
return m.Msg
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type StreamingRequest struct {
|
||||
Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *StreamingRequest) Reset() { *m = StreamingRequest{} }
|
||||
func (m *StreamingRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*StreamingRequest) ProtoMessage() {}
|
||||
func (*StreamingRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_70718d389c4b1652, []int{3}
|
||||
}
|
||||
|
||||
func (m *StreamingRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_StreamingRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *StreamingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_StreamingRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *StreamingRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_StreamingRequest.Merge(m, src)
|
||||
}
|
||||
func (m *StreamingRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_StreamingRequest.Size(m)
|
||||
}
|
||||
func (m *StreamingRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_StreamingRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_StreamingRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *StreamingRequest) GetCount() int64 {
|
||||
if m != nil {
|
||||
return m.Count
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type StreamingResponse struct {
|
||||
Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *StreamingResponse) Reset() { *m = StreamingResponse{} }
|
||||
func (m *StreamingResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*StreamingResponse) ProtoMessage() {}
|
||||
func (*StreamingResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_70718d389c4b1652, []int{4}
|
||||
}
|
||||
|
||||
func (m *StreamingResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_StreamingResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *StreamingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_StreamingResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *StreamingResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_StreamingResponse.Merge(m, src)
|
||||
}
|
||||
func (m *StreamingResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_StreamingResponse.Size(m)
|
||||
}
|
||||
func (m *StreamingResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_StreamingResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_StreamingResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *StreamingResponse) GetCount() int64 {
|
||||
if m != nil {
|
||||
return m.Count
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type Ping struct {
|
||||
Stroke int64 `protobuf:"varint,1,opt,name=stroke,proto3" json:"stroke,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Ping) Reset() { *m = Ping{} }
|
||||
func (m *Ping) String() string { return proto.CompactTextString(m) }
|
||||
func (*Ping) ProtoMessage() {}
|
||||
func (*Ping) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_70718d389c4b1652, []int{5}
|
||||
}
|
||||
|
||||
func (m *Ping) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Ping.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Ping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Ping.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Ping) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Ping.Merge(m, src)
|
||||
}
|
||||
func (m *Ping) XXX_Size() int {
|
||||
return xxx_messageInfo_Ping.Size(m)
|
||||
}
|
||||
func (m *Ping) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Ping.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Ping proto.InternalMessageInfo
|
||||
|
||||
func (m *Ping) GetStroke() int64 {
|
||||
if m != nil {
|
||||
return m.Stroke
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type Pong struct {
|
||||
Stroke int64 `protobuf:"varint,1,opt,name=stroke,proto3" json:"stroke,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Pong) Reset() { *m = Pong{} }
|
||||
func (m *Pong) String() string { return proto.CompactTextString(m) }
|
||||
func (*Pong) ProtoMessage() {}
|
||||
func (*Pong) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_70718d389c4b1652, []int{6}
|
||||
}
|
||||
|
||||
func (m *Pong) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Pong.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Pong) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Pong.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Pong) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Pong.Merge(m, src)
|
||||
}
|
||||
func (m *Pong) XXX_Size() int {
|
||||
return xxx_messageInfo_Pong.Size(m)
|
||||
}
|
||||
func (m *Pong) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Pong.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Pong proto.InternalMessageInfo
|
||||
|
||||
func (m *Pong) GetStroke() int64 {
|
||||
if m != nil {
|
||||
return m.Stroke
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Message)(nil), "idiomatic.Message")
|
||||
proto.RegisterType((*Request)(nil), "idiomatic.Request")
|
||||
proto.RegisterType((*Response)(nil), "idiomatic.Response")
|
||||
proto.RegisterType((*StreamingRequest)(nil), "idiomatic.StreamingRequest")
|
||||
proto.RegisterType((*StreamingResponse)(nil), "idiomatic.StreamingResponse")
|
||||
proto.RegisterType((*Ping)(nil), "idiomatic.Ping")
|
||||
proto.RegisterType((*Pong)(nil), "idiomatic.Pong")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("proto/idiomatic.proto", fileDescriptor_70718d389c4b1652) }
|
||||
|
||||
var fileDescriptor_70718d389c4b1652 = []byte{
|
||||
// 270 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0x3f, 0x4f, 0xc3, 0x30,
|
||||
0x10, 0xc5, 0x6b, 0xb5, 0xa4, 0xcd, 0x2d, 0x6d, 0x8f, 0x3f, 0x42, 0x69, 0x41, 0xc8, 0x53, 0x58,
|
||||
0x4a, 0x29, 0x23, 0x1b, 0x0c, 0x88, 0x01, 0x09, 0x85, 0x8d, 0xcd, 0x14, 0xcb, 0xb2, 0xa8, 0xed,
|
||||
0x92, 0x73, 0x07, 0x3e, 0x1b, 0x5f, 0x0e, 0xc5, 0x71, 0x4a, 0x8a, 0xca, 0x76, 0xf7, 0x7e, 0xef,
|
||||
0x4e, 0xef, 0x6c, 0x38, 0x5e, 0x97, 0xce, 0xbb, 0x2b, 0xfd, 0xae, 0x9d, 0x11, 0x5e, 0x2f, 0x67,
|
||||
0xa1, 0xc7, 0x74, 0x2b, 0xf0, 0x09, 0xf4, 0x9f, 0x24, 0x91, 0x50, 0x12, 0x47, 0xd0, 0x25, 0xf1,
|
||||
0x75, 0xca, 0x2e, 0x58, 0x9e, 0x16, 0x55, 0xc9, 0xcf, 0xa0, 0x5f, 0xc8, 0xcf, 0x8d, 0x24, 0x8f,
|
||||
0x08, 0x3d, 0x2b, 0x8c, 0x8c, 0x34, 0xd4, 0x7c, 0x0a, 0x83, 0x42, 0xd2, 0xda, 0x59, 0x0a, 0xc3,
|
||||
0x86, 0x54, 0x33, 0x6c, 0x48, 0xf1, 0x1c, 0x46, 0x2f, 0xbe, 0x94, 0xc2, 0x68, 0xab, 0x9a, 0x2d,
|
||||
0x47, 0x70, 0xb0, 0x74, 0x1b, 0xeb, 0x83, 0xaf, 0x5b, 0xd4, 0x0d, 0xbf, 0x84, 0x71, 0xcb, 0x19,
|
||||
0x17, 0xee, 0xb7, 0x9e, 0x43, 0xef, 0x59, 0x5b, 0x85, 0x27, 0x90, 0x90, 0x2f, 0xdd, 0x87, 0x8c,
|
||||
0x38, 0x76, 0x81, 0xbb, 0xff, 0xf9, 0xe2, 0x9b, 0x41, 0xfa, 0xd8, 0x1c, 0x8f, 0xd7, 0xd0, 0xbb,
|
||||
0x17, 0xab, 0x15, 0xe2, 0xec, 0xf7, 0x85, 0x62, 0xd4, 0xec, 0x70, 0x47, 0xab, 0x43, 0xf1, 0x0e,
|
||||
0x3e, 0x40, 0x52, 0x67, 0xc5, 0x49, 0xcb, 0xf0, 0xf7, 0xd0, 0x6c, 0xba, 0x1f, 0x36, 0x6b, 0xe6,
|
||||
0x0c, 0x17, 0x30, 0xa8, 0x2e, 0x09, 0x69, 0x87, 0x2d, 0x77, 0x25, 0x66, 0x3b, 0x82, 0xb3, 0x8a,
|
||||
0x77, 0x72, 0x36, 0x67, 0x77, 0xe3, 0xd7, 0x61, 0xf8, 0xc0, 0xdb, 0x2d, 0x7d, 0x4b, 0x82, 0x70,
|
||||
0xf3, 0x13, 0x00, 0x00, 0xff, 0xff, 0xf8, 0xd7, 0xdf, 0x69, 0xea, 0x01, 0x00, 0x00,
|
||||
}
|
||||
284
test/template/proto/idiomatic.pb.micro.go
Normal file
284
test/template/proto/idiomatic.pb.micro.go
Normal file
@@ -0,0 +1,284 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: proto/idiomatic.proto
|
||||
|
||||
package idiomatic
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
import (
|
||||
context "context"
|
||||
api "github.com/micro/go-micro/v3/api"
|
||||
client "github.com/micro/go-micro/v3/client"
|
||||
server "github.com/micro/go-micro/v3/server"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ api.Endpoint
|
||||
var _ context.Context
|
||||
var _ client.Option
|
||||
var _ server.Option
|
||||
|
||||
// Api Endpoints for Idiomatic service
|
||||
|
||||
func NewIdiomaticEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{}
|
||||
}
|
||||
|
||||
// Client API for Idiomatic service
|
||||
|
||||
type IdiomaticService interface {
|
||||
Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error)
|
||||
Stream(ctx context.Context, in *StreamingRequest, opts ...client.CallOption) (Idiomatic_StreamService, error)
|
||||
PingPong(ctx context.Context, opts ...client.CallOption) (Idiomatic_PingPongService, error)
|
||||
}
|
||||
|
||||
type idiomaticService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewIdiomaticService(name string, c client.Client) IdiomaticService {
|
||||
return &idiomaticService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *idiomaticService) Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) {
|
||||
req := c.c.NewRequest(c.name, "Idiomatic.Call", in)
|
||||
out := new(Response)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *idiomaticService) Stream(ctx context.Context, in *StreamingRequest, opts ...client.CallOption) (Idiomatic_StreamService, error) {
|
||||
req := c.c.NewRequest(c.name, "Idiomatic.Stream", &StreamingRequest{})
|
||||
stream, err := c.c.Stream(ctx, req, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := stream.Send(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &idiomaticServiceStream{stream}, nil
|
||||
}
|
||||
|
||||
type Idiomatic_StreamService interface {
|
||||
Context() context.Context
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Recv() (*StreamingResponse, error)
|
||||
}
|
||||
|
||||
type idiomaticServiceStream struct {
|
||||
stream client.Stream
|
||||
}
|
||||
|
||||
func (x *idiomaticServiceStream) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *idiomaticServiceStream) Context() context.Context {
|
||||
return x.stream.Context()
|
||||
}
|
||||
|
||||
func (x *idiomaticServiceStream) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *idiomaticServiceStream) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *idiomaticServiceStream) Recv() (*StreamingResponse, error) {
|
||||
m := new(StreamingResponse)
|
||||
err := x.stream.Recv(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (c *idiomaticService) PingPong(ctx context.Context, opts ...client.CallOption) (Idiomatic_PingPongService, error) {
|
||||
req := c.c.NewRequest(c.name, "Idiomatic.PingPong", &Ping{})
|
||||
stream, err := c.c.Stream(ctx, req, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &idiomaticServicePingPong{stream}, nil
|
||||
}
|
||||
|
||||
type Idiomatic_PingPongService interface {
|
||||
Context() context.Context
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Send(*Ping) error
|
||||
Recv() (*Pong, error)
|
||||
}
|
||||
|
||||
type idiomaticServicePingPong struct {
|
||||
stream client.Stream
|
||||
}
|
||||
|
||||
func (x *idiomaticServicePingPong) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *idiomaticServicePingPong) Context() context.Context {
|
||||
return x.stream.Context()
|
||||
}
|
||||
|
||||
func (x *idiomaticServicePingPong) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *idiomaticServicePingPong) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *idiomaticServicePingPong) Send(m *Ping) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *idiomaticServicePingPong) Recv() (*Pong, error) {
|
||||
m := new(Pong)
|
||||
err := x.stream.Recv(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// Server API for Idiomatic service
|
||||
|
||||
type IdiomaticHandler interface {
|
||||
Call(context.Context, *Request, *Response) error
|
||||
Stream(context.Context, *StreamingRequest, Idiomatic_StreamStream) error
|
||||
PingPong(context.Context, Idiomatic_PingPongStream) error
|
||||
}
|
||||
|
||||
func RegisterIdiomaticHandler(s server.Server, hdlr IdiomaticHandler, opts ...server.HandlerOption) error {
|
||||
type idiomatic interface {
|
||||
Call(ctx context.Context, in *Request, out *Response) error
|
||||
Stream(ctx context.Context, stream server.Stream) error
|
||||
PingPong(ctx context.Context, stream server.Stream) error
|
||||
}
|
||||
type Idiomatic struct {
|
||||
idiomatic
|
||||
}
|
||||
h := &idiomaticHandler{hdlr}
|
||||
return s.Handle(s.NewHandler(&Idiomatic{h}, opts...))
|
||||
}
|
||||
|
||||
type idiomaticHandler struct {
|
||||
IdiomaticHandler
|
||||
}
|
||||
|
||||
func (h *idiomaticHandler) Call(ctx context.Context, in *Request, out *Response) error {
|
||||
return h.IdiomaticHandler.Call(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *idiomaticHandler) Stream(ctx context.Context, stream server.Stream) error {
|
||||
m := new(StreamingRequest)
|
||||
if err := stream.Recv(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return h.IdiomaticHandler.Stream(ctx, m, &idiomaticStreamStream{stream})
|
||||
}
|
||||
|
||||
type Idiomatic_StreamStream interface {
|
||||
Context() context.Context
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Send(*StreamingResponse) error
|
||||
}
|
||||
|
||||
type idiomaticStreamStream struct {
|
||||
stream server.Stream
|
||||
}
|
||||
|
||||
func (x *idiomaticStreamStream) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *idiomaticStreamStream) Context() context.Context {
|
||||
return x.stream.Context()
|
||||
}
|
||||
|
||||
func (x *idiomaticStreamStream) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *idiomaticStreamStream) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *idiomaticStreamStream) Send(m *StreamingResponse) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (h *idiomaticHandler) PingPong(ctx context.Context, stream server.Stream) error {
|
||||
return h.IdiomaticHandler.PingPong(ctx, &idiomaticPingPongStream{stream})
|
||||
}
|
||||
|
||||
type Idiomatic_PingPongStream interface {
|
||||
Context() context.Context
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Send(*Pong) error
|
||||
Recv() (*Ping, error)
|
||||
}
|
||||
|
||||
type idiomaticPingPongStream struct {
|
||||
stream server.Stream
|
||||
}
|
||||
|
||||
func (x *idiomaticPingPongStream) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *idiomaticPingPongStream) Context() context.Context {
|
||||
return x.stream.Context()
|
||||
}
|
||||
|
||||
func (x *idiomaticPingPongStream) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *idiomaticPingPongStream) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *idiomaticPingPongStream) Send(m *Pong) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *idiomaticPingPongStream) Recv() (*Ping, error) {
|
||||
m := new(Ping)
|
||||
if err := x.stream.Recv(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
39
test/template/proto/idiomatic.proto
Normal file
39
test/template/proto/idiomatic.proto
Normal file
@@ -0,0 +1,39 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package idiomatic;
|
||||
|
||||
option go_package = "proto;idiomatic";
|
||||
|
||||
service Idiomatic {
|
||||
rpc Call(Request) returns (Response) {}
|
||||
rpc Stream(StreamingRequest) returns (stream StreamingResponse) {}
|
||||
rpc PingPong(stream Ping) returns (stream Pong) {}
|
||||
}
|
||||
|
||||
message Message {
|
||||
string say = 1;
|
||||
}
|
||||
|
||||
message Request {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message Response {
|
||||
string msg = 1;
|
||||
}
|
||||
|
||||
message StreamingRequest {
|
||||
int64 count = 1;
|
||||
}
|
||||
|
||||
message StreamingResponse {
|
||||
int64 count = 1;
|
||||
}
|
||||
|
||||
message Ping {
|
||||
int64 stroke = 1;
|
||||
}
|
||||
|
||||
message Pong {
|
||||
int64 stroke = 1;
|
||||
}
|
||||
Reference in New Issue
Block a user