regen files with never protoc (#6)

* regen files with never protoc
* rewrite import path

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-08-19 17:47:17 +03:00 committed by GitHub
parent 7a407d5792
commit 06136312bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
357 changed files with 8755 additions and 3310 deletions

2
.github/generate.sh vendored
View File

@ -9,7 +9,7 @@ curl -s -o proto/google/api/http.proto -L https://raw.githubusercontent.com/goog
for PROTO in $PROTOS; do for PROTO in $PROTOS; do
echo $PROTO echo $PROTO
protoc -I./proto -I. -I$(dirname $PROTO) --go_out=plugins=grpc,paths=source_relative:. --micro_out=paths=source_relative:. $PROTO protoc -I./proto -I. -I$(dirname $PROTO) --go-grpc_out=paths=source_relative:. --go_out=paths=source_relative:. --micro_out=paths=source_relative:. $PROTO
done done
rm -r proto rm -r proto

View File

@ -1,5 +1,11 @@
run: run:
deadline: 5m deadline: 5m
modules-download-mode: readonly
skip-dirs:
- util/mdns.new
skip-files:
- ".*\\.pb\\.go$"
- ".*\\.pb\\.micro\\.go$"
linters: linters:
disable-all: false disable-all: false
enable-all: false enable-all: false
@ -24,4 +30,11 @@ linters:
- interfacer - interfacer
- typecheck - typecheck
- dupl - dupl
output:
format: colored-line-number
# print lines of code with issue, default is true
print-issued-lines: true
# print linter name in the end of issue text, default is true
print-linter-name: true
# make issues output unique by line, default is true
uniq-by-line: true

View File

@ -5,8 +5,8 @@ import (
"regexp" "regexp"
"strings" "strings"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/micro/go-micro/v3/server" "github.com/unistack-org/micro/v3/server"
) )
type Api interface { type Api interface {

View File

@ -4,13 +4,13 @@ package api
import ( import (
"net/http" "net/http"
goapi "github.com/micro/go-micro/v3/api" goapi "github.com/unistack-org/micro/v3/api"
"github.com/micro/go-micro/v3/api/handler" "github.com/unistack-org/micro/v3/api/handler"
api "github.com/micro/go-micro/v3/api/proto" api "github.com/unistack-org/micro/v3/api/proto"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
"github.com/micro/go-micro/v3/errors" "github.com/unistack-org/micro/v3/errors"
"github.com/micro/go-micro/v3/util/ctx" "github.com/unistack-org/micro/v3/util/ctx"
"github.com/micro/go-micro/v3/util/router" "github.com/unistack-org/micro/v3/util/router"
) )
type apiHandler struct { type apiHandler struct {

View File

@ -7,7 +7,7 @@ import (
"net/http" "net/http"
"strings" "strings"
api "github.com/micro/go-micro/v3/api/proto" api "github.com/unistack-org/micro/v3/api/proto"
"github.com/oxtoacart/bpool" "github.com/oxtoacart/bpool"
) )

View File

@ -11,9 +11,9 @@ import (
"time" "time"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/micro/go-micro/v3/api/handler" "github.com/unistack-org/micro/v3/api/handler"
proto "github.com/micro/go-micro/v3/api/proto" proto "github.com/unistack-org/micro/v3/api/proto"
"github.com/micro/go-micro/v3/util/ctx" "github.com/unistack-org/micro/v3/util/ctx"
"github.com/oxtoacart/bpool" "github.com/oxtoacart/bpool"
) )

View File

@ -9,9 +9,9 @@ import (
"net/http/httputil" "net/http/httputil"
"net/url" "net/url"
"github.com/micro/go-micro/v3/api" "github.com/unistack-org/micro/v3/api"
"github.com/micro/go-micro/v3/api/handler" "github.com/unistack-org/micro/v3/api/handler"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
) )
const ( const (

View File

@ -6,13 +6,13 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"github.com/micro/go-micro/v3/api/handler" "github.com/unistack-org/micro/v3/api/handler"
"github.com/micro/go-micro/v3/api/resolver" "github.com/unistack-org/micro/v3/api/resolver"
"github.com/micro/go-micro/v3/api/resolver/vpath" "github.com/unistack-org/micro/v3/api/resolver/vpath"
"github.com/micro/go-micro/v3/api/router" "github.com/unistack-org/micro/v3/api/router"
regRouter "github.com/micro/go-micro/v3/api/router/registry" regRouter "github.com/unistack-org/micro/v3/api/router/registry"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/micro/go-micro/v3/registry/memory" "github.com/unistack-org/micro/v3/registry/memory"
) )
func testHttp(t *testing.T, path, service, ns string) { func testHttp(t *testing.T, path, service, ns string) {

View File

@ -1,9 +1,9 @@
package handler package handler
import ( import (
"github.com/micro/go-micro/v3/api/router" "github.com/unistack-org/micro/v3/api/router"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
"github.com/micro/go-micro/v3/client/grpc" "github.com/unistack-org/micro/v3/client/grpc"
) )
var ( var (

View File

@ -9,19 +9,19 @@ import (
"strings" "strings"
jsonpatch "github.com/evanphx/json-patch/v5" jsonpatch "github.com/evanphx/json-patch/v5"
"github.com/micro/go-micro/v3/api" "github.com/unistack-org/micro/v3/api"
"github.com/micro/go-micro/v3/api/handler" "github.com/unistack-org/micro/v3/api/handler"
"github.com/micro/go-micro/v3/api/internal/proto" "github.com/unistack-org/micro/v3/api/internal/proto"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
"github.com/micro/go-micro/v3/codec/jsonrpc" "github.com/unistack-org/micro/v3/codec/jsonrpc"
"github.com/micro/go-micro/v3/codec/protorpc" "github.com/unistack-org/micro/v3/codec/protorpc"
"github.com/micro/go-micro/v3/errors" "github.com/unistack-org/micro/v3/errors"
"github.com/micro/go-micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
"github.com/micro/go-micro/v3/metadata" "github.com/unistack-org/micro/v3/metadata"
"github.com/micro/go-micro/v3/util/ctx" "github.com/unistack-org/micro/v3/util/ctx"
"github.com/micro/go-micro/v3/util/qson" "github.com/unistack-org/micro/v3/util/qson"
"github.com/micro/go-micro/v3/util/router" "github.com/unistack-org/micro/v3/util/router"
"github.com/oxtoacart/bpool" "github.com/oxtoacart/bpool"
) )

View File

@ -7,7 +7,7 @@ import (
"testing" "testing"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
go_api "github.com/micro/go-micro/v3/api/proto" go_api "github.com/unistack-org/micro/v3/api/proto"
) )
func TestRequestPayloadFromRequest(t *testing.T) { func TestRequestPayloadFromRequest(t *testing.T) {

View File

@ -12,11 +12,11 @@ import (
"github.com/gobwas/httphead" "github.com/gobwas/httphead"
"github.com/gobwas/ws" "github.com/gobwas/ws"
"github.com/gobwas/ws/wsutil" "github.com/gobwas/ws/wsutil"
"github.com/micro/go-micro/v3/api" "github.com/unistack-org/micro/v3/api"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
raw "github.com/micro/go-micro/v3/codec/bytes" raw "github.com/unistack-org/micro/v3/codec/bytes"
"github.com/micro/go-micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
"github.com/micro/go-micro/v3/util/router" "github.com/unistack-org/micro/v3/util/router"
) )
// serveWebsocket will stream rpc back over websockets assuming json // serveWebsocket will stream rpc back over websockets assuming json

View File

@ -12,9 +12,9 @@ import (
"net/url" "net/url"
"strings" "strings"
"github.com/micro/go-micro/v3/api" "github.com/unistack-org/micro/v3/api"
"github.com/micro/go-micro/v3/api/handler" "github.com/unistack-org/micro/v3/api/handler"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
) )
const ( const (

View File

@ -1,68 +1,81 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.6.1
// source: api/proto/api.proto // source: api/proto/api.proto
package go_api package go_api
import ( import (
fmt "fmt"
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
math "math" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
) )
// Reference imports to suppress errors if they are not otherwise used. const (
var _ = proto.Marshal // Verify that this generated code is sufficiently up-to-date.
var _ = fmt.Errorf _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
var _ = math.Inf // Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion to ensure that this generated file // This is a compile-time assertion that a sufficiently up-to-date version
// is compatible with the proto package it is being compiled against. // of the legacy proto package is being used.
// A compilation error at this line likely means your copy of the const _ = proto.ProtoPackageIsVersion4
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type Pair struct { type Pair struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` state protoimpl.MessageState
Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"` sizeCache protoimpl.SizeCache
XXX_NoUnkeyedLiteral struct{} `json:"-"` unknownFields protoimpl.UnknownFields
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"`
} }
func (m *Pair) Reset() { *m = Pair{} } func (x *Pair) Reset() {
func (m *Pair) String() string { return proto.CompactTextString(m) } *x = Pair{}
func (*Pair) ProtoMessage() {} if protoimpl.UnsafeEnabled {
mi := &file_api_proto_api_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Pair) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Pair) ProtoMessage() {}
func (x *Pair) ProtoReflect() protoreflect.Message {
mi := &file_api_proto_api_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Pair.ProtoReflect.Descriptor instead.
func (*Pair) Descriptor() ([]byte, []int) { func (*Pair) Descriptor() ([]byte, []int) {
return fileDescriptor_2df576b66d12087a, []int{0} return file_api_proto_api_proto_rawDescGZIP(), []int{0}
} }
func (m *Pair) XXX_Unmarshal(b []byte) error { func (x *Pair) GetKey() string {
return xxx_messageInfo_Pair.Unmarshal(m, b) if x != nil {
} return x.Key
func (m *Pair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Pair.Marshal(b, m, deterministic)
}
func (m *Pair) XXX_Merge(src proto.Message) {
xxx_messageInfo_Pair.Merge(m, src)
}
func (m *Pair) XXX_Size() int {
return xxx_messageInfo_Pair.Size(m)
}
func (m *Pair) XXX_DiscardUnknown() {
xxx_messageInfo_Pair.DiscardUnknown(m)
}
var xxx_messageInfo_Pair proto.InternalMessageInfo
func (m *Pair) GetKey() string {
if m != nil {
return m.Key
} }
return "" return ""
} }
func (m *Pair) GetValues() []string { func (x *Pair) GetValues() []string {
if m != nil { if x != nil {
return m.Values return x.Values
} }
return nil return nil
} }
@ -70,88 +83,96 @@ func (m *Pair) GetValues() []string {
// A HTTP request as RPC // A HTTP request as RPC
// Forward by the api handler // Forward by the api handler
type Request struct { type Request struct {
Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` state protoimpl.MessageState
Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` sizeCache protoimpl.SizeCache
Header map[string]*Pair `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` unknownFields protoimpl.UnknownFields
Get map[string]*Pair `protobuf:"bytes,4,rep,name=get,proto3" json:"get,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
Post map[string]*Pair `protobuf:"bytes,5,rep,name=post,proto3" json:"post,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
Body string `protobuf:"bytes,6,opt,name=body,proto3" json:"body,omitempty"` Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
Url string `protobuf:"bytes,7,opt,name=url,proto3" json:"url,omitempty"` Header map[string]*Pair `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` Get map[string]*Pair `protobuf:"bytes,4,rep,name=get,proto3" json:"get,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
XXX_unrecognized []byte `json:"-"` Post map[string]*Pair `protobuf:"bytes,5,rep,name=post,proto3" json:"post,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
XXX_sizecache int32 `json:"-"` Body string `protobuf:"bytes,6,opt,name=body,proto3" json:"body,omitempty"` // raw request body; if not application/x-www-form-urlencoded
Url string `protobuf:"bytes,7,opt,name=url,proto3" json:"url,omitempty"`
} }
func (m *Request) Reset() { *m = Request{} } func (x *Request) Reset() {
func (m *Request) String() string { return proto.CompactTextString(m) } *x = Request{}
func (*Request) ProtoMessage() {} if protoimpl.UnsafeEnabled {
mi := &file_api_proto_api_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Request) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Request) ProtoMessage() {}
func (x *Request) ProtoReflect() protoreflect.Message {
mi := &file_api_proto_api_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Request.ProtoReflect.Descriptor instead.
func (*Request) Descriptor() ([]byte, []int) { func (*Request) Descriptor() ([]byte, []int) {
return fileDescriptor_2df576b66d12087a, []int{1} return file_api_proto_api_proto_rawDescGZIP(), []int{1}
} }
func (m *Request) XXX_Unmarshal(b []byte) error { func (x *Request) GetMethod() string {
return xxx_messageInfo_Request.Unmarshal(m, b) if x != nil {
} return x.Method
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) GetMethod() string {
if m != nil {
return m.Method
} }
return "" return ""
} }
func (m *Request) GetPath() string { func (x *Request) GetPath() string {
if m != nil { if x != nil {
return m.Path return x.Path
} }
return "" return ""
} }
func (m *Request) GetHeader() map[string]*Pair { func (x *Request) GetHeader() map[string]*Pair {
if m != nil { if x != nil {
return m.Header return x.Header
} }
return nil return nil
} }
func (m *Request) GetGet() map[string]*Pair { func (x *Request) GetGet() map[string]*Pair {
if m != nil { if x != nil {
return m.Get return x.Get
} }
return nil return nil
} }
func (m *Request) GetPost() map[string]*Pair { func (x *Request) GetPost() map[string]*Pair {
if m != nil { if x != nil {
return m.Post return x.Post
} }
return nil return nil
} }
func (m *Request) GetBody() string { func (x *Request) GetBody() string {
if m != nil { if x != nil {
return m.Body return x.Body
} }
return "" return ""
} }
func (m *Request) GetUrl() string { func (x *Request) GetUrl() string {
if m != nil { if x != nil {
return m.Url return x.Url
} }
return "" return ""
} }
@ -159,56 +180,64 @@ func (m *Request) GetUrl() string {
// A HTTP response as RPC // A HTTP response as RPC
// Expected response for the api handler // Expected response for the api handler
type Response struct { type Response struct {
StatusCode int32 `protobuf:"varint,1,opt,name=statusCode,proto3" json:"statusCode,omitempty"` state protoimpl.MessageState
Header map[string]*Pair `protobuf:"bytes,2,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` sizeCache protoimpl.SizeCache
Body string `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"` unknownFields protoimpl.UnknownFields
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` StatusCode int32 `protobuf:"varint,1,opt,name=statusCode,proto3" json:"statusCode,omitempty"`
XXX_sizecache int32 `json:"-"` Header map[string]*Pair `protobuf:"bytes,2,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
Body string `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
} }
func (m *Response) Reset() { *m = Response{} } func (x *Response) Reset() {
func (m *Response) String() string { return proto.CompactTextString(m) } *x = Response{}
func (*Response) ProtoMessage() {} if protoimpl.UnsafeEnabled {
mi := &file_api_proto_api_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Response) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Response) ProtoMessage() {}
func (x *Response) ProtoReflect() protoreflect.Message {
mi := &file_api_proto_api_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Response.ProtoReflect.Descriptor instead.
func (*Response) Descriptor() ([]byte, []int) { func (*Response) Descriptor() ([]byte, []int) {
return fileDescriptor_2df576b66d12087a, []int{2} return file_api_proto_api_proto_rawDescGZIP(), []int{2}
} }
func (m *Response) XXX_Unmarshal(b []byte) error { func (x *Response) GetStatusCode() int32 {
return xxx_messageInfo_Response.Unmarshal(m, b) if x != nil {
} return x.StatusCode
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) GetStatusCode() int32 {
if m != nil {
return m.StatusCode
} }
return 0 return 0
} }
func (m *Response) GetHeader() map[string]*Pair { func (x *Response) GetHeader() map[string]*Pair {
if m != nil { if x != nil {
return m.Header return x.Header
} }
return nil return nil
} }
func (m *Response) GetBody() string { func (x *Response) GetBody() string {
if m != nil { if x != nil {
return m.Body return x.Body
} }
return "" return ""
} }
@ -216,6 +245,10 @@ func (m *Response) GetBody() string {
// A HTTP event as RPC // A HTTP event as RPC
// Forwarded by the event handler // Forwarded by the event handler
type Event struct { type Event struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// e.g login // e.g login
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// uuid // uuid
@ -225,111 +258,254 @@ type Event struct {
// event headers // event headers
Header map[string]*Pair `protobuf:"bytes,4,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` Header map[string]*Pair `protobuf:"bytes,4,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
// the event data // the event data
Data string `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` Data string `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
} }
func (m *Event) Reset() { *m = Event{} } func (x *Event) Reset() {
func (m *Event) String() string { return proto.CompactTextString(m) } *x = Event{}
func (*Event) ProtoMessage() {} if protoimpl.UnsafeEnabled {
mi := &file_api_proto_api_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Event) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Event) ProtoMessage() {}
func (x *Event) ProtoReflect() protoreflect.Message {
mi := &file_api_proto_api_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Event.ProtoReflect.Descriptor instead.
func (*Event) Descriptor() ([]byte, []int) { func (*Event) Descriptor() ([]byte, []int) {
return fileDescriptor_2df576b66d12087a, []int{3} return file_api_proto_api_proto_rawDescGZIP(), []int{3}
} }
func (m *Event) XXX_Unmarshal(b []byte) error { func (x *Event) GetName() string {
return xxx_messageInfo_Event.Unmarshal(m, b) if x != nil {
} return x.Name
func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Event.Marshal(b, m, deterministic)
}
func (m *Event) XXX_Merge(src proto.Message) {
xxx_messageInfo_Event.Merge(m, src)
}
func (m *Event) XXX_Size() int {
return xxx_messageInfo_Event.Size(m)
}
func (m *Event) XXX_DiscardUnknown() {
xxx_messageInfo_Event.DiscardUnknown(m)
}
var xxx_messageInfo_Event proto.InternalMessageInfo
func (m *Event) GetName() string {
if m != nil {
return m.Name
} }
return "" return ""
} }
func (m *Event) GetId() string { func (x *Event) GetId() string {
if m != nil { if x != nil {
return m.Id return x.Id
} }
return "" return ""
} }
func (m *Event) GetTimestamp() int64 { func (x *Event) GetTimestamp() int64 {
if m != nil { if x != nil {
return m.Timestamp return x.Timestamp
} }
return 0 return 0
} }
func (m *Event) GetHeader() map[string]*Pair { func (x *Event) GetHeader() map[string]*Pair {
if m != nil { if x != nil {
return m.Header return x.Header
} }
return nil return nil
} }
func (m *Event) GetData() string { func (x *Event) GetData() string {
if m != nil { if x != nil {
return m.Data return x.Data
} }
return "" return ""
} }
func init() { var File_api_proto_api_proto protoreflect.FileDescriptor
proto.RegisterType((*Pair)(nil), "go.api.Pair")
proto.RegisterType((*Request)(nil), "go.api.Request") var file_api_proto_api_proto_rawDesc = []byte{
proto.RegisterMapType((map[string]*Pair)(nil), "go.api.Request.GetEntry") 0x0a, 0x13, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2e,
proto.RegisterMapType((map[string]*Pair)(nil), "go.api.Request.HeaderEntry") 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x67, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x22, 0x30, 0x0a,
proto.RegisterMapType((map[string]*Pair)(nil), "go.api.Request.PostEntry") 0x04, 0x50, 0x61, 0x69, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
proto.RegisterType((*Response)(nil), "go.api.Response") 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65,
proto.RegisterMapType((map[string]*Pair)(nil), "go.api.Response.HeaderEntry") 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22,
proto.RegisterType((*Event)(nil), "go.api.Event") 0xc1, 0x03, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d,
proto.RegisterMapType((map[string]*Pair)(nil), "go.api.Event.HeaderEntry") 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74,
0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x33, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65,
0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x2e, 0x61, 0x70, 0x69,
0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45,
0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x03,
0x67, 0x65, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x2e, 0x61,
0x70, 0x69, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x6e,
0x74, 0x72, 0x79, 0x52, 0x03, 0x67, 0x65, 0x74, 0x12, 0x2d, 0x0a, 0x04, 0x70, 0x6f, 0x73, 0x74,
0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x45, 0x6e, 0x74, 0x72,
0x79, 0x52, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18,
0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x75,
0x72, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x1a, 0x47, 0x0a,
0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03,
0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x22,
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e,
0x67, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x61, 0x69, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c,
0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x44, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x45, 0x6e, 0x74,
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x6b, 0x65, 0x79, 0x12, 0x22, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x67, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x61, 0x69,
0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x45, 0x0a, 0x09,
0x50, 0x6f, 0x73, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x22, 0x0a, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x67, 0x6f, 0x2e,
0x61, 0x70, 0x69, 0x2e, 0x50, 0x61, 0x69, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a,
0x02, 0x38, 0x01, 0x22, 0xbd, 0x01, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65,
0x12, 0x34, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06,
0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x1a, 0x47, 0x0a, 0x0b, 0x48, 0x65,
0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x22, 0x0a, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x67, 0x6f, 0x2e,
0x61, 0x70, 0x69, 0x2e, 0x50, 0x61, 0x69, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a,
0x02, 0x38, 0x01, 0x22, 0xd9, 0x01, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69,
0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03,
0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12,
0x31, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x19, 0x2e, 0x67, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x48,
0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64,
0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x47, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x22, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x67, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x50, 0x61, 0x69, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
func init() { proto.RegisterFile("api/proto/api.proto", fileDescriptor_2df576b66d12087a) } var (
file_api_proto_api_proto_rawDescOnce sync.Once
file_api_proto_api_proto_rawDescData = file_api_proto_api_proto_rawDesc
)
var fileDescriptor_2df576b66d12087a = []byte{ func file_api_proto_api_proto_rawDescGZIP() []byte {
// 393 bytes of a gzipped FileDescriptorProto file_api_proto_api_proto_rawDescOnce.Do(func() {
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xcd, 0xce, 0xd3, 0x30, file_api_proto_api_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_proto_api_proto_rawDescData)
0x10, 0x54, 0xe2, 0x24, 0x6d, 0xb6, 0x08, 0x21, 0x23, 0x21, 0x53, 0x2a, 0x54, 0xe5, 0x54, 0x21, })
0x91, 0x42, 0xcb, 0x01, 0x71, 0x85, 0xaa, 0x1c, 0x2b, 0xbf, 0x81, 0xab, 0x58, 0x6d, 0x44, 0x13, return file_api_proto_api_proto_rawDescData
0x9b, 0xd8, 0xa9, 0xd4, 0x87, 0xe3, 0xc0, 0x63, 0xf0, 0x36, 0xc8, 0x1b, 0xf7, 0xe7, 0xab, 0xfa, }
0x5d, 0xbe, 0xaf, 0xb7, 0x89, 0x3d, 0x3b, 0x3b, 0x3b, 0xeb, 0xc0, 0x6b, 0xa1, 0xcb, 0xa9, 0x6e,
0x94, 0x55, 0x53, 0xa1, 0xcb, 0x1c, 0x11, 0x4d, 0x36, 0x2a, 0x17, 0xba, 0xcc, 0x3e, 0x41, 0xb4, var file_api_proto_api_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
0x12, 0x65, 0x43, 0x5f, 0x01, 0xf9, 0x25, 0x0f, 0x2c, 0x18, 0x07, 0x93, 0x94, 0x3b, 0x48, 0xdf, var file_api_proto_api_proto_goTypes = []interface{}{
0x40, 0xb2, 0x17, 0xbb, 0x56, 0x1a, 0x16, 0x8e, 0xc9, 0x24, 0xe5, 0xfe, 0x2b, 0xfb, 0x4b, 0xa0, (*Pair)(nil), // 0: go.api.Pair
0xc7, 0xe5, 0xef, 0x56, 0x1a, 0xeb, 0x38, 0x95, 0xb4, 0x5b, 0x55, 0xf8, 0x42, 0xff, 0x45, 0x29, (*Request)(nil), // 1: go.api.Request
0x44, 0x5a, 0xd8, 0x2d, 0x0b, 0xf1, 0x14, 0x31, 0x9d, 0x43, 0xb2, 0x95, 0xa2, 0x90, 0x0d, 0x23, (*Response)(nil), // 2: go.api.Response
0x63, 0x32, 0x19, 0xcc, 0xde, 0xe5, 0x9d, 0x85, 0xdc, 0x8b, 0xe5, 0x3f, 0xf1, 0x76, 0x51, 0xdb, (*Event)(nil), // 3: go.api.Event
0xe6, 0xc0, 0x3d, 0x95, 0x7e, 0x00, 0xb2, 0x91, 0x96, 0x45, 0x58, 0xc1, 0xae, 0x2b, 0x96, 0xd2, nil, // 4: go.api.Request.HeaderEntry
0x76, 0x74, 0x47, 0xa2, 0x1f, 0x21, 0xd2, 0xca, 0x58, 0x16, 0x23, 0xf9, 0xed, 0x35, 0x79, 0xa5, nil, // 5: go.api.Request.GetEntry
0x8c, 0x67, 0x23, 0xcd, 0x79, 0x5c, 0xab, 0xe2, 0xc0, 0x92, 0xce, 0xa3, 0xc3, 0x2e, 0x85, 0xb6, nil, // 6: go.api.Request.PostEntry
0xd9, 0xb1, 0x5e, 0x97, 0x42, 0xdb, 0xec, 0x86, 0x4b, 0x18, 0x5c, 0xf8, 0xba, 0x11, 0x53, 0x06, nil, // 7: go.api.Response.HeaderEntry
0x31, 0x06, 0x83, 0xb3, 0x0e, 0x66, 0x2f, 0x8e, 0x6d, 0x5d, 0xaa, 0xbc, 0xbb, 0xfa, 0x16, 0x7e, nil, // 8: go.api.Event.HeaderEntry
0x0d, 0x86, 0x3f, 0xa0, 0x7f, 0xb4, 0xfb, 0x0c, 0x95, 0x05, 0xa4, 0xa7, 0x39, 0x9e, 0x2e, 0x93, }
0xfd, 0x09, 0xa0, 0xcf, 0xa5, 0xd1, 0xaa, 0x36, 0x92, 0xbe, 0x07, 0x30, 0x56, 0xd8, 0xd6, 0x7c, var file_api_proto_api_proto_depIdxs = []int32{
0x57, 0x85, 0x44, 0xb5, 0x98, 0x5f, 0x9c, 0xd0, 0x2f, 0xa7, 0xc5, 0x85, 0x98, 0xec, 0xe8, 0x9c, 4, // 0: go.api.Request.header:type_name -> go.api.Request.HeaderEntry
0x6c, 0xa7, 0x70, 0x73, 0x73, 0xc7, 0x78, 0xc9, 0x39, 0xde, 0xbb, 0x85, 0x99, 0xfd, 0x0b, 0x20, 5, // 1: go.api.Request.get:type_name -> go.api.Request.GetEntry
0x5e, 0xec, 0x65, 0x8d, 0x5b, 0xac, 0x45, 0x25, 0xbd, 0x08, 0x62, 0xfa, 0x12, 0xc2, 0xb2, 0xf0, 6, // 2: go.api.Request.post:type_name -> go.api.Request.PostEntry
0x6f, 0x2f, 0x2c, 0x0b, 0x3a, 0x82, 0xd4, 0x96, 0x95, 0x34, 0x56, 0x54, 0x1a, 0xfd, 0x10, 0x7e, 7, // 3: go.api.Response.header:type_name -> go.api.Response.HeaderEntry
0x3e, 0xa0, 0x9f, 0x4f, 0xe3, 0x45, 0x0f, 0x1f, 0x0e, 0x36, 0x78, 0x6c, 0xb6, 0x42, 0x58, 0xc1, 8, // 4: go.api.Event.header:type_name -> go.api.Event.HeaderEntry
0xe2, 0xae, 0xa9, 0xc3, 0x77, 0x9b, 0x6d, 0x9d, 0xe0, 0x0f, 0x3a, 0xff, 0x1f, 0x00, 0x00, 0xff, 0, // 5: go.api.Request.HeaderEntry.value:type_name -> go.api.Pair
0xff, 0xd4, 0x6d, 0x70, 0x51, 0xb7, 0x03, 0x00, 0x00, 0, // 6: go.api.Request.GetEntry.value:type_name -> go.api.Pair
0, // 7: go.api.Request.PostEntry.value:type_name -> go.api.Pair
0, // 8: go.api.Response.HeaderEntry.value:type_name -> go.api.Pair
0, // 9: go.api.Event.HeaderEntry.value:type_name -> go.api.Pair
10, // [10:10] is the sub-list for method output_type
10, // [10:10] is the sub-list for method input_type
10, // [10:10] is the sub-list for extension type_name
10, // [10:10] is the sub-list for extension extendee
0, // [0:10] is the sub-list for field type_name
}
func init() { file_api_proto_api_proto_init() }
func file_api_proto_api_proto_init() {
if File_api_proto_api_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_api_proto_api_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Pair); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_proto_api_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Request); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_proto_api_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Response); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_proto_api_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Event); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_proto_api_proto_rawDesc,
NumEnums: 0,
NumMessages: 9,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_api_proto_api_proto_goTypes,
DependencyIndexes: file_api_proto_api_proto_depIdxs,
MessageInfos: file_api_proto_api_proto_msgTypes,
}.Build()
File_api_proto_api_proto = out.File
file_api_proto_api_proto_rawDesc = nil
file_api_proto_api_proto_goTypes = nil
file_api_proto_api_proto_depIdxs = nil
} }

View File

@ -6,7 +6,7 @@ import (
"net/http" "net/http"
"strings" "strings"
"github.com/micro/go-micro/v3/api/resolver" "github.com/unistack-org/micro/v3/api/resolver"
) )
type Resolver struct { type Resolver struct {

View File

@ -4,7 +4,7 @@ package host
import ( import (
"net/http" "net/http"
"github.com/micro/go-micro/v3/api/resolver" "github.com/unistack-org/micro/v3/api/resolver"
) )
type Resolver struct { type Resolver struct {

View File

@ -1,7 +1,7 @@
package resolver package resolver
import ( import (
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
) )
type Options struct { type Options struct {

View File

@ -5,7 +5,7 @@ import (
"net/http" "net/http"
"strings" "strings"
"github.com/micro/go-micro/v3/api/resolver" "github.com/unistack-org/micro/v3/api/resolver"
) )
type Resolver struct { type Resolver struct {

View File

@ -7,8 +7,8 @@ import (
"net/http" "net/http"
"strings" "strings"
"github.com/micro/go-micro/v3/api/resolver" "github.com/unistack-org/micro/v3/api/resolver"
"github.com/micro/go-micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
"golang.org/x/net/publicsuffix" "golang.org/x/net/publicsuffix"
) )

View File

@ -5,7 +5,7 @@ import (
"net/url" "net/url"
"testing" "testing"
"github.com/micro/go-micro/v3/api/resolver/vpath" "github.com/unistack-org/micro/v3/api/resolver/vpath"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View File

@ -7,7 +7,7 @@ import (
"regexp" "regexp"
"strings" "strings"
"github.com/micro/go-micro/v3/api/resolver" "github.com/unistack-org/micro/v3/api/resolver"
) )
func NewResolver(opts ...resolver.Option) resolver.Resolver { func NewResolver(opts ...resolver.Option) resolver.Resolver {

View File

@ -1,10 +1,10 @@
package router package router
import ( import (
"github.com/micro/go-micro/v3/api/resolver" "github.com/unistack-org/micro/v3/api/resolver"
"github.com/micro/go-micro/v3/api/resolver/vpath" "github.com/unistack-org/micro/v3/api/resolver/vpath"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/micro/go-micro/v3/registry/mdns" "github.com/unistack-org/micro/v3/registry/mdns"
) )
type Options struct { type Options struct {

View File

@ -10,13 +10,13 @@ import (
"sync" "sync"
"time" "time"
"github.com/micro/go-micro/v3/api" "github.com/unistack-org/micro/v3/api"
"github.com/micro/go-micro/v3/api/router" "github.com/unistack-org/micro/v3/api/router"
"github.com/micro/go-micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
"github.com/micro/go-micro/v3/metadata" "github.com/unistack-org/micro/v3/metadata"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/micro/go-micro/v3/registry/cache" "github.com/unistack-org/micro/v3/registry/cache"
util "github.com/micro/go-micro/v3/util/router" util "github.com/unistack-org/micro/v3/util/router"
) )
// endpoint struct, that holds compiled pcre // endpoint struct, that holds compiled pcre

View File

@ -3,7 +3,7 @@ package registry
import ( import (
"testing" "testing"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View File

@ -4,7 +4,7 @@ package router
import ( import (
"net/http" "net/http"
"github.com/micro/go-micro/v3/api" "github.com/unistack-org/micro/v3/api"
) )
// Router is used to determine an endpoint for a request // Router is used to determine an endpoint for a request

View File

@ -9,20 +9,20 @@ import (
"testing" "testing"
"time" "time"
"github.com/micro/go-micro/v3/api" "github.com/unistack-org/micro/v3/api"
"github.com/micro/go-micro/v3/api/handler" "github.com/unistack-org/micro/v3/api/handler"
"github.com/micro/go-micro/v3/api/handler/rpc" "github.com/unistack-org/micro/v3/api/handler/rpc"
"github.com/micro/go-micro/v3/api/router" "github.com/unistack-org/micro/v3/api/router"
rregistry "github.com/micro/go-micro/v3/api/router/registry" rregistry "github.com/unistack-org/micro/v3/api/router/registry"
rstatic "github.com/micro/go-micro/v3/api/router/static" rstatic "github.com/unistack-org/micro/v3/api/router/static"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
gcli "github.com/micro/go-micro/v3/client/grpc" gcli "github.com/unistack-org/micro/v3/client/grpc"
rmemory "github.com/micro/go-micro/v3/registry/memory" rmemory "github.com/unistack-org/micro/v3/registry/memory"
rt "github.com/micro/go-micro/v3/router" rt "github.com/unistack-org/micro/v3/router"
regRouter "github.com/micro/go-micro/v3/router/registry" regRouter "github.com/unistack-org/micro/v3/router/registry"
"github.com/micro/go-micro/v3/server" "github.com/unistack-org/micro/v3/server"
gsrv "github.com/micro/go-micro/v3/server/grpc" gsrv "github.com/unistack-org/micro/v3/server/grpc"
pb "github.com/micro/go-micro/v3/server/grpc/proto" pb "github.com/unistack-org/micro/v3/server/grpc/proto"
) )
// server is used to implement helloworld.GreeterServer. // server is used to implement helloworld.GreeterServer.

View File

@ -8,13 +8,13 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/micro/go-micro/v3/api" "github.com/unistack-org/micro/v3/api"
"github.com/micro/go-micro/v3/api/router" "github.com/unistack-org/micro/v3/api/router"
"github.com/micro/go-micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
"github.com/micro/go-micro/v3/metadata" "github.com/unistack-org/micro/v3/metadata"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
rutil "github.com/micro/go-micro/v3/util/registry" rutil "github.com/unistack-org/micro/v3/util/registry"
util "github.com/micro/go-micro/v3/util/router" util "github.com/unistack-org/micro/v3/util/router"
) )
type endpoint struct { type endpoint struct {

View File

@ -7,8 +7,8 @@ import (
"net" "net"
"os" "os"
"github.com/micro/go-micro/v3/api/server/acme" "github.com/unistack-org/micro/v3/api/server/acme"
"github.com/micro/go-micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
"golang.org/x/crypto/acme/autocert" "golang.org/x/crypto/acme/autocert"
) )

View File

@ -8,8 +8,8 @@ import (
"time" "time"
"github.com/caddyserver/certmagic" "github.com/caddyserver/certmagic"
"github.com/micro/go-micro/v3/api/server/acme" "github.com/unistack-org/micro/v3/api/server/acme"
"github.com/micro/go-micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
) )
type certmagicProvider struct { type certmagicProvider struct {

View File

@ -10,8 +10,8 @@ import (
"time" "time"
"github.com/caddyserver/certmagic" "github.com/caddyserver/certmagic"
"github.com/micro/go-micro/v3/store" "github.com/unistack-org/micro/v3/store"
"github.com/micro/go-micro/v3/sync" "github.com/unistack-org/micro/v3/sync"
) )
// File represents a "File" that will be stored in store.Store - the contents and last modified time // File represents a "File" that will be stored in store.Store - the contents and last modified time

View File

@ -9,9 +9,9 @@ import (
"sync" "sync"
"github.com/gorilla/handlers" "github.com/gorilla/handlers"
"github.com/micro/go-micro/v3/api/server" "github.com/unistack-org/micro/v3/api/server"
"github.com/micro/go-micro/v3/api/server/cors" "github.com/unistack-org/micro/v3/api/server/cors"
"github.com/micro/go-micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
) )
type httpServer struct { type httpServer struct {

View File

@ -4,8 +4,8 @@ import (
"crypto/tls" "crypto/tls"
"net/http" "net/http"
"github.com/micro/go-micro/v3/api/resolver" "github.com/unistack-org/micro/v3/api/resolver"
"github.com/micro/go-micro/v3/api/server/acme" "github.com/unistack-org/micro/v3/api/server/acme"
) )
type Option func(o *Options) type Option func(o *Options)

View File

@ -1,268 +1,249 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.6.1
// source: api/service/proto/api.proto // source: api/service/proto/api.proto
package go_micro_api package go_micro_api
import ( import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
codes "google.golang.org/grpc/codes" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
status "google.golang.org/grpc/status" reflect "reflect"
math "math" sync "sync"
) )
// Reference imports to suppress errors if they are not otherwise used. const (
var _ = proto.Marshal // Verify that this generated code is sufficiently up-to-date.
var _ = fmt.Errorf _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
var _ = math.Inf // Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion to ensure that this generated file // This is a compile-time assertion that a sufficiently up-to-date version
// is compatible with the proto package it is being compiled against. // of the legacy proto package is being used.
// A compilation error at this line likely means your copy of the const _ = proto.ProtoPackageIsVersion4
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type Endpoint struct { type Endpoint struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` state protoimpl.MessageState
Host []string `protobuf:"bytes,2,rep,name=host,proto3" json:"host,omitempty"` sizeCache protoimpl.SizeCache
Path []string `protobuf:"bytes,3,rep,name=path,proto3" json:"path,omitempty"` unknownFields protoimpl.UnknownFields
Method []string `protobuf:"bytes,4,rep,name=method,proto3" json:"method,omitempty"`
Stream bool `protobuf:"varint,5,opt,name=stream,proto3" json:"stream,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` Host []string `protobuf:"bytes,2,rep,name=host,proto3" json:"host,omitempty"`
XXX_unrecognized []byte `json:"-"` Path []string `protobuf:"bytes,3,rep,name=path,proto3" json:"path,omitempty"`
XXX_sizecache int32 `json:"-"` Method []string `protobuf:"bytes,4,rep,name=method,proto3" json:"method,omitempty"`
Stream bool `protobuf:"varint,5,opt,name=stream,proto3" json:"stream,omitempty"`
} }
func (m *Endpoint) Reset() { *m = Endpoint{} } func (x *Endpoint) Reset() {
func (m *Endpoint) String() string { return proto.CompactTextString(m) } *x = Endpoint{}
func (*Endpoint) ProtoMessage() {} if protoimpl.UnsafeEnabled {
mi := &file_api_service_proto_api_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Endpoint) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Endpoint) ProtoMessage() {}
func (x *Endpoint) ProtoReflect() protoreflect.Message {
mi := &file_api_service_proto_api_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Endpoint.ProtoReflect.Descriptor instead.
func (*Endpoint) Descriptor() ([]byte, []int) { func (*Endpoint) Descriptor() ([]byte, []int) {
return fileDescriptor_c4a48b6b680b5c31, []int{0} return file_api_service_proto_api_proto_rawDescGZIP(), []int{0}
} }
func (m *Endpoint) XXX_Unmarshal(b []byte) error { func (x *Endpoint) GetName() string {
return xxx_messageInfo_Endpoint.Unmarshal(m, b) if x != nil {
} return x.Name
func (m *Endpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Endpoint.Marshal(b, m, deterministic)
}
func (m *Endpoint) XXX_Merge(src proto.Message) {
xxx_messageInfo_Endpoint.Merge(m, src)
}
func (m *Endpoint) XXX_Size() int {
return xxx_messageInfo_Endpoint.Size(m)
}
func (m *Endpoint) XXX_DiscardUnknown() {
xxx_messageInfo_Endpoint.DiscardUnknown(m)
}
var xxx_messageInfo_Endpoint proto.InternalMessageInfo
func (m *Endpoint) GetName() string {
if m != nil {
return m.Name
} }
return "" return ""
} }
func (m *Endpoint) GetHost() []string { func (x *Endpoint) GetHost() []string {
if m != nil { if x != nil {
return m.Host return x.Host
} }
return nil return nil
} }
func (m *Endpoint) GetPath() []string { func (x *Endpoint) GetPath() []string {
if m != nil { if x != nil {
return m.Path return x.Path
} }
return nil return nil
} }
func (m *Endpoint) GetMethod() []string { func (x *Endpoint) GetMethod() []string {
if m != nil { if x != nil {
return m.Method return x.Method
} }
return nil return nil
} }
func (m *Endpoint) GetStream() bool { func (x *Endpoint) GetStream() bool {
if m != nil { if x != nil {
return m.Stream return x.Stream
} }
return false return false
} }
type EmptyResponse struct { type EmptyResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"` state protoimpl.MessageState
XXX_unrecognized []byte `json:"-"` sizeCache protoimpl.SizeCache
XXX_sizecache int32 `json:"-"` unknownFields protoimpl.UnknownFields
} }
func (m *EmptyResponse) Reset() { *m = EmptyResponse{} } func (x *EmptyResponse) Reset() {
func (m *EmptyResponse) String() string { return proto.CompactTextString(m) } *x = EmptyResponse{}
func (*EmptyResponse) ProtoMessage() {} if protoimpl.UnsafeEnabled {
mi := &file_api_service_proto_api_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EmptyResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EmptyResponse) ProtoMessage() {}
func (x *EmptyResponse) ProtoReflect() protoreflect.Message {
mi := &file_api_service_proto_api_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EmptyResponse.ProtoReflect.Descriptor instead.
func (*EmptyResponse) Descriptor() ([]byte, []int) { func (*EmptyResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_c4a48b6b680b5c31, []int{1} return file_api_service_proto_api_proto_rawDescGZIP(), []int{1}
} }
func (m *EmptyResponse) XXX_Unmarshal(b []byte) error { var File_api_service_proto_api_proto protoreflect.FileDescriptor
return xxx_messageInfo_EmptyResponse.Unmarshal(m, b)
} var file_api_service_proto_api_proto_rawDesc = []byte{
func (m *EmptyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 0x0a, 0x1b, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x70, 0x72,
return xxx_messageInfo_EmptyResponse.Marshal(b, m, deterministic) 0x6f, 0x74, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x67,
} 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x22, 0x76, 0x0a, 0x08, 0x45,
func (m *EmptyResponse) XXX_Merge(src proto.Message) { 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
xxx_messageInfo_EmptyResponse.Merge(m, src) 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68,
} 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12,
func (m *EmptyResponse) XXX_Size() int { 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x70,
return xxx_messageInfo_EmptyResponse.Size(m) 0x61, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x04, 0x20,
} 0x03, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73,
func (m *EmptyResponse) XXX_DiscardUnknown() { 0x74, 0x72, 0x65, 0x61, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x72,
xxx_messageInfo_EmptyResponse.DiscardUnknown(m) 0x65, 0x61, 0x6d, 0x22, 0x0f, 0x0a, 0x0d, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x32, 0x8d, 0x01, 0x0a, 0x03, 0x41, 0x70, 0x69, 0x12, 0x41, 0x0a, 0x08,
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69,
0x63, 0x72, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74,
0x1a, 0x1b, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x43, 0x0a, 0x0a, 0x44, 0x65, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x16, 0x2e,
0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x6e, 0x64,
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x1a, 0x1b, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f,
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var xxx_messageInfo_EmptyResponse proto.InternalMessageInfo var (
file_api_service_proto_api_proto_rawDescOnce sync.Once
file_api_service_proto_api_proto_rawDescData = file_api_service_proto_api_proto_rawDesc
)
func init() { func file_api_service_proto_api_proto_rawDescGZIP() []byte {
proto.RegisterType((*Endpoint)(nil), "go.micro.api.Endpoint") file_api_service_proto_api_proto_rawDescOnce.Do(func() {
proto.RegisterType((*EmptyResponse)(nil), "go.micro.api.EmptyResponse") file_api_service_proto_api_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_service_proto_api_proto_rawDescData)
})
return file_api_service_proto_api_proto_rawDescData
} }
func init() { proto.RegisterFile("api/service/proto/api.proto", fileDescriptor_c4a48b6b680b5c31) } var file_api_service_proto_api_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_api_service_proto_api_proto_goTypes = []interface{}{
var fileDescriptor_c4a48b6b680b5c31 = []byte{ (*Endpoint)(nil), // 0: go.micro.api.Endpoint
// 212 bytes of a gzipped FileDescriptorProto (*EmptyResponse)(nil), // 1: go.micro.api.EmptyResponse
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0xd0, 0xc1, 0x4a, 0x03, 0x31, }
0x10, 0x80, 0x61, 0xd7, 0xad, 0x65, 0x1d, 0x14, 0x21, 0x87, 0x12, 0xec, 0x65, 0xd9, 0x53, 0x4f, var file_api_service_proto_api_proto_depIdxs = []int32{
0x59, 0xd0, 0x27, 0x28, 0xda, 0x17, 0xd8, 0x37, 0x88, 0xed, 0xd0, 0x9d, 0x43, 0x32, 0x43, 0x32, 0, // 0: go.micro.api.Api.Register:input_type -> go.micro.api.Endpoint
0x14, 0x7c, 0x08, 0xdf, 0x59, 0x12, 0x2b, 0x2c, 0x5e, 0xbd, 0xfd, 0xf3, 0x1d, 0x86, 0x61, 0x60, 0, // 1: go.micro.api.Api.Deregister:input_type -> go.micro.api.Endpoint
0xeb, 0x85, 0xc6, 0x8c, 0xe9, 0x42, 0x47, 0x1c, 0x25, 0xb1, 0xf2, 0xe8, 0x85, 0x5c, 0x2d, 0xf3, 1, // 2: go.micro.api.Api.Register:output_type -> go.micro.api.EmptyResponse
0x70, 0x66, 0x17, 0xe8, 0x98, 0xd8, 0x79, 0xa1, 0xe1, 0x02, 0xdd, 0x21, 0x9e, 0x84, 0x29, 0xaa, 1, // 3: go.micro.api.Api.Deregister:output_type -> go.micro.api.EmptyResponse
0x31, 0xb0, 0x8a, 0x3e, 0xa0, 0x6d, 0xfa, 0x66, 0x77, 0x3f, 0xd5, 0x2e, 0x36, 0x73, 0x56, 0x7b, 2, // [2:4] is the sub-list for method output_type
0xdb, 0xb7, 0xc5, 0x4a, 0x17, 0x13, 0xaf, 0xb3, 0x6d, 0x7f, 0xac, 0xb4, 0xd9, 0xc0, 0x3a, 0xa0, 0, // [0:2] is the sub-list for method input_type
0xce, 0x7c, 0xb2, 0xab, 0xaa, 0xd7, 0xa9, 0x78, 0xd6, 0x84, 0x3e, 0xd8, 0xbb, 0xbe, 0xd9, 0x75, 0, // [0:0] is the sub-list for extension type_name
0xd3, 0x75, 0x1a, 0x9e, 0xe0, 0xf1, 0x10, 0x44, 0x3f, 0x27, 0xcc, 0xc2, 0x31, 0xe3, 0xcb, 0x57, 0, // [0:0] is the sub-list for extension extendee
0x03, 0xed, 0x5e, 0xc8, 0xec, 0xa1, 0x9b, 0xf0, 0x4c, 0x59, 0x31, 0x99, 0x8d, 0x5b, 0xde, 0xea, 0, // [0:0] is the sub-list for field type_name
0x7e, 0x0f, 0x7d, 0xde, 0xfe, 0xf1, 0xe5, 0xa2, 0xe1, 0xc6, 0xbc, 0x01, 0xbc, 0x63, 0xfa, 0xdf,
0x92, 0x8f, 0x75, 0xfd, 0xd6, 0xeb, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x46, 0x62, 0x67, 0x30,
0x4c, 0x01, 0x00, 0x00,
} }
// Reference imports to suppress errors if they are not otherwise used. func init() { file_api_service_proto_api_proto_init() }
var _ context.Context func file_api_service_proto_api_proto_init() {
var _ grpc.ClientConn if File_api_service_proto_api_proto != nil {
return
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// ApiClient is the client API for Api service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ApiClient interface {
Register(ctx context.Context, in *Endpoint, opts ...grpc.CallOption) (*EmptyResponse, error)
Deregister(ctx context.Context, in *Endpoint, opts ...grpc.CallOption) (*EmptyResponse, error)
}
type apiClient struct {
cc *grpc.ClientConn
}
func NewApiClient(cc *grpc.ClientConn) ApiClient {
return &apiClient{cc}
}
func (c *apiClient) Register(ctx context.Context, in *Endpoint, opts ...grpc.CallOption) (*EmptyResponse, error) {
out := new(EmptyResponse)
err := c.cc.Invoke(ctx, "/go.micro.api.Api/Register", in, out, opts...)
if err != nil {
return nil, err
} }
return out, nil if !protoimpl.UnsafeEnabled {
} file_api_service_proto_api_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Endpoint); i {
func (c *apiClient) Deregister(ctx context.Context, in *Endpoint, opts ...grpc.CallOption) (*EmptyResponse, error) { case 0:
out := new(EmptyResponse) return &v.state
err := c.cc.Invoke(ctx, "/go.micro.api.Api/Deregister", in, out, opts...) case 1:
if err != nil { return &v.sizeCache
return nil, err case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_service_proto_api_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EmptyResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
return out, nil type x struct{}
} out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
// ApiServer is the server API for Api service. GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
type ApiServer interface { RawDescriptor: file_api_service_proto_api_proto_rawDesc,
Register(context.Context, *Endpoint) (*EmptyResponse, error) NumEnums: 0,
Deregister(context.Context, *Endpoint) (*EmptyResponse, error) NumMessages: 2,
} NumExtensions: 0,
NumServices: 1,
// UnimplementedApiServer can be embedded to have forward compatible implementations.
type UnimplementedApiServer struct {
}
func (*UnimplementedApiServer) Register(ctx context.Context, req *Endpoint) (*EmptyResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Register not implemented")
}
func (*UnimplementedApiServer) Deregister(ctx context.Context, req *Endpoint) (*EmptyResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Deregister not implemented")
}
func RegisterApiServer(s *grpc.Server, srv ApiServer) {
s.RegisterService(&_Api_serviceDesc, srv)
}
func _Api_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Endpoint)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ApiServer).Register(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/go.micro.api.Api/Register",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ApiServer).Register(ctx, req.(*Endpoint))
}
return interceptor(ctx, in, info, handler)
}
func _Api_Deregister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Endpoint)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ApiServer).Deregister(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/go.micro.api.Api/Deregister",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ApiServer).Deregister(ctx, req.(*Endpoint))
}
return interceptor(ctx, in, info, handler)
}
var _Api_serviceDesc = grpc.ServiceDesc{
ServiceName: "go.micro.api.Api",
HandlerType: (*ApiServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Register",
Handler: _Api_Register_Handler,
}, },
{ GoTypes: file_api_service_proto_api_proto_goTypes,
MethodName: "Deregister", DependencyIndexes: file_api_service_proto_api_proto_depIdxs,
Handler: _Api_Deregister_Handler, MessageInfos: file_api_service_proto_api_proto_msgTypes,
}, }.Build()
}, File_api_service_proto_api_proto = out.File
Streams: []grpc.StreamDesc{}, file_api_service_proto_api_proto_rawDesc = nil
Metadata: "api/service/proto/api.proto", file_api_service_proto_api_proto_goTypes = nil
file_api_service_proto_api_proto_depIdxs = nil
} }

View File

@ -11,9 +11,9 @@ import (
import ( import (
context "context" context "context"
api "github.com/micro/go-micro/v3/api" api "github.com/unistack-org/micro/v3/api"
client "github.com/micro/go-micro/v3/client" client "github.com/unistack-org/micro/v3/client"
server "github.com/micro/go-micro/v3/server" server "github.com/unistack-org/micro/v3/server"
) )
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.

View File

@ -0,0 +1,126 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package go_micro_api
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// ApiClient is the client API for Api 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.
type ApiClient interface {
Register(ctx context.Context, in *Endpoint, opts ...grpc.CallOption) (*EmptyResponse, error)
Deregister(ctx context.Context, in *Endpoint, opts ...grpc.CallOption) (*EmptyResponse, error)
}
type apiClient struct {
cc grpc.ClientConnInterface
}
func NewApiClient(cc grpc.ClientConnInterface) ApiClient {
return &apiClient{cc}
}
func (c *apiClient) Register(ctx context.Context, in *Endpoint, opts ...grpc.CallOption) (*EmptyResponse, error) {
out := new(EmptyResponse)
err := c.cc.Invoke(ctx, "/go.micro.api.Api/Register", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *apiClient) Deregister(ctx context.Context, in *Endpoint, opts ...grpc.CallOption) (*EmptyResponse, error) {
out := new(EmptyResponse)
err := c.cc.Invoke(ctx, "/go.micro.api.Api/Deregister", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ApiServer is the server API for Api service.
// All implementations must embed UnimplementedApiServer
// for forward compatibility
type ApiServer interface {
Register(context.Context, *Endpoint) (*EmptyResponse, error)
Deregister(context.Context, *Endpoint) (*EmptyResponse, error)
mustEmbedUnimplementedApiServer()
}
// UnimplementedApiServer must be embedded to have forward compatible implementations.
type UnimplementedApiServer struct {
}
func (*UnimplementedApiServer) Register(context.Context, *Endpoint) (*EmptyResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Register not implemented")
}
func (*UnimplementedApiServer) Deregister(context.Context, *Endpoint) (*EmptyResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Deregister not implemented")
}
func (*UnimplementedApiServer) mustEmbedUnimplementedApiServer() {}
func RegisterApiServer(s *grpc.Server, srv ApiServer) {
s.RegisterService(&_Api_serviceDesc, srv)
}
func _Api_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Endpoint)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ApiServer).Register(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/go.micro.api.Api/Register",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ApiServer).Register(ctx, req.(*Endpoint))
}
return interceptor(ctx, in, info, handler)
}
func _Api_Deregister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Endpoint)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ApiServer).Deregister(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/go.micro.api.Api/Deregister",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ApiServer).Deregister(ctx, req.(*Endpoint))
}
return interceptor(ctx, in, info, handler)
}
var _Api_serviceDesc = grpc.ServiceDesc{
ServiceName: "go.micro.api.Api",
HandlerType: (*ApiServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Register",
Handler: _Api_Register_Handler,
},
{
MethodName: "Deregister",
Handler: _Api_Deregister_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "api/service/proto/api.proto",
}

View File

@ -5,9 +5,9 @@ import (
"sync" "sync"
"time" "time"
"github.com/micro/go-micro/v3/auth" "github.com/unistack-org/micro/v3/auth"
"github.com/micro/go-micro/v3/util/token" "github.com/unistack-org/micro/v3/util/token"
"github.com/micro/go-micro/v3/util/token/jwt" "github.com/unistack-org/micro/v3/util/token/jwt"
) )
// NewAuth returns a new instance of the Auth service // NewAuth returns a new instance of the Auth service

View File

@ -2,7 +2,7 @@ package noop
import ( import (
"github.com/google/uuid" "github.com/google/uuid"
"github.com/micro/go-micro/v3/auth" "github.com/unistack-org/micro/v3/auth"
) )
func NewAuth(opts ...auth.Option) auth.Auth { func NewAuth(opts ...auth.Option) auth.Auth {

View File

@ -4,7 +4,7 @@ import (
"context" "context"
"time" "time"
"github.com/micro/go-micro/v3/store" "github.com/unistack-org/micro/v3/store"
) )
func NewOptions(opts ...Option) Options { func NewOptions(opts ...Option) Options {

View File

@ -18,15 +18,15 @@ import (
"time" "time"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/micro/go-micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
"github.com/micro/go-micro/v3/codec/json" "github.com/unistack-org/micro/v3/codec/json"
merr "github.com/micro/go-micro/v3/errors" merr "github.com/unistack-org/micro/v3/errors"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/micro/go-micro/v3/registry/cache" "github.com/unistack-org/micro/v3/registry/cache"
"github.com/micro/go-micro/v3/registry/mdns" "github.com/unistack-org/micro/v3/registry/mdns"
maddr "github.com/micro/go-micro/v3/util/addr" maddr "github.com/unistack-org/micro/v3/util/addr"
mnet "github.com/micro/go-micro/v3/util/net" mnet "github.com/unistack-org/micro/v3/util/net"
mls "github.com/micro/go-micro/v3/util/tls" mls "github.com/unistack-org/micro/v3/util/tls"
"golang.org/x/net/http2" "golang.org/x/net/http2"
) )

View File

@ -6,9 +6,9 @@ import (
"time" "time"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/micro/go-micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/micro/go-micro/v3/registry/memory" "github.com/unistack-org/micro/v3/registry/memory"
) )
var ( var (

View File

@ -4,7 +4,7 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/micro/go-micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
) )
// Handle registers the handler for the given pattern. // Handle registers the handler for the given pattern.

View File

@ -9,9 +9,9 @@ import (
"time" "time"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/micro/go-micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
maddr "github.com/micro/go-micro/v3/util/addr" maddr "github.com/unistack-org/micro/v3/util/addr"
mnet "github.com/micro/go-micro/v3/util/net" mnet "github.com/unistack-org/micro/v3/util/net"
) )
type memoryBroker struct { type memoryBroker struct {

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/micro/go-micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
) )
func TestMemoryBroker(t *testing.T) { func TestMemoryBroker(t *testing.T) {

View File

@ -3,7 +3,7 @@ package nats
import ( import (
"context" "context"
"github.com/micro/go-micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
) )
// setBrokerOption returns a function to setup a context with given value // setBrokerOption returns a function to setup a context with given value

View File

@ -7,10 +7,10 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/micro/go-micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
"github.com/micro/go-micro/v3/codec/json" "github.com/unistack-org/micro/v3/codec/json"
"github.com/micro/go-micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
"github.com/micro/go-micro/v3/registry/mdns" "github.com/unistack-org/micro/v3/registry/mdns"
nats "github.com/nats-io/nats.go" nats "github.com/nats-io/nats.go"
) )

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/micro/go-micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
nats "github.com/nats-io/nats.go" nats "github.com/nats-io/nats.go"
) )

View File

@ -1,7 +1,7 @@
package nats package nats
import ( import (
"github.com/micro/go-micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
nats "github.com/nats-io/nats.go" nats "github.com/nats-io/nats.go"
) )

View File

@ -4,8 +4,8 @@ import (
"context" "context"
"crypto/tls" "crypto/tls"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
) )
type Options struct { type Options struct {

View File

@ -9,8 +9,8 @@ import (
"path/filepath" "path/filepath"
docker "github.com/fsouza/go-dockerclient" docker "github.com/fsouza/go-dockerclient"
"github.com/micro/go-micro/v3/build" "github.com/unistack-org/micro/v3/build"
"github.com/micro/go-micro/v3/logger" "github.com/unistack-org/micro/v3/logger"
) )
type dockerBuild struct { type dockerBuild struct {

View File

@ -6,7 +6,7 @@ import (
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"github.com/micro/go-micro/v3/build" "github.com/unistack-org/micro/v3/build"
) )
type goBuild struct { type goBuild struct {

View File

@ -5,7 +5,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/micro/go-micro/v3/build" "github.com/unistack-org/micro/v3/build"
) )
type tarBuild struct{} type tarBuild struct{}

View File

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"github.com/bradfitz/gomemcache/memcache" "github.com/bradfitz/gomemcache/memcache"
"github.com/micro/go-micro/v3/cache" "github.com/unistack-org/micro/v3/cache"
) )
type memcacheCache struct { type memcacheCache struct {

View File

@ -4,8 +4,8 @@ package memory
import ( import (
"sync" "sync"
"github.com/micro/go-micro/v3/cache" "github.com/unistack-org/micro/v3/cache"
"github.com/micro/go-micro/v3/errors" "github.com/unistack-org/micro/v3/errors"
) )
type memoryCache struct { type memoryCache struct {

View File

@ -4,7 +4,7 @@ import (
"context" "context"
"time" "time"
"github.com/micro/go-micro/v3/util/backoff" "github.com/unistack-org/micro/v3/util/backoff"
) )
type BackoffFunc func(ctx context.Context, req Request, attempts int) (time.Duration, error) type BackoffFunc func(ctx context.Context, req Request, attempts int) (time.Duration, error)

View File

@ -7,7 +7,7 @@ import (
"hash/fnv" "hash/fnv"
"time" "time"
"github.com/micro/go-micro/v3/metadata" "github.com/unistack-org/micro/v3/metadata"
cache "github.com/patrickmn/go-cache" cache "github.com/patrickmn/go-cache"
) )

View File

@ -5,7 +5,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/micro/go-micro/v3/metadata" "github.com/unistack-org/micro/v3/metadata"
) )
func TestCache(t *testing.T) { func TestCache(t *testing.T) {

View File

@ -5,7 +5,7 @@ import (
"context" "context"
"time" "time"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
) )
// Client is the interface used to make requests to services. // Client is the interface used to make requests to services.

View File

@ -9,8 +9,8 @@ import (
"github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
"github.com/micro/go-micro/v3/codec/bytes" "github.com/unistack-org/micro/v3/codec/bytes"
"github.com/oxtoacart/bpool" "github.com/oxtoacart/bpool"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/encoding" "google.golang.org/grpc/encoding"

View File

@ -1,7 +1,7 @@
package grpc package grpc
import ( import (
"github.com/micro/go-micro/v3/errors" "github.com/unistack-org/micro/v3/errors"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
) )

View File

@ -11,11 +11,11 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/micro/go-micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
raw "github.com/micro/go-micro/v3/codec/bytes" raw "github.com/unistack-org/micro/v3/codec/bytes"
"github.com/micro/go-micro/v3/errors" "github.com/unistack-org/micro/v3/errors"
"github.com/micro/go-micro/v3/metadata" "github.com/unistack-org/micro/v3/metadata"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"

View File

@ -5,12 +5,12 @@ import (
"net" "net"
"testing" "testing"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
"github.com/micro/go-micro/v3/errors" "github.com/unistack-org/micro/v3/errors"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/micro/go-micro/v3/registry/memory" "github.com/unistack-org/micro/v3/registry/memory"
"github.com/micro/go-micro/v3/router" "github.com/unistack-org/micro/v3/router"
regRouter "github.com/micro/go-micro/v3/router/registry" regRouter "github.com/unistack-org/micro/v3/router/registry"
pgrpc "google.golang.org/grpc" pgrpc "google.golang.org/grpc"
pb "google.golang.org/grpc/examples/helloworld/helloworld" pb "google.golang.org/grpc/examples/helloworld/helloworld"
) )

View File

@ -1,7 +1,7 @@
package grpc package grpc
import ( import (
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
) )
type grpcEvent struct { type grpcEvent struct {

View File

@ -5,7 +5,7 @@ import (
"context" "context"
"crypto/tls" "crypto/tls"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/encoding" "google.golang.org/grpc/encoding"
) )

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
) )
type grpcRequest struct { type grpcRequest struct {

View File

@ -3,8 +3,8 @@ package grpc
import ( import (
"strings" "strings"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
"github.com/micro/go-micro/v3/codec/bytes" "github.com/unistack-org/micro/v3/codec/bytes"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/encoding" "google.golang.org/grpc/encoding"
) )

View File

@ -5,7 +5,7 @@ import (
"io" "io"
"sync" "sync"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
"google.golang.org/grpc" "google.golang.org/grpc"
) )

View File

@ -4,8 +4,8 @@ import (
"context" "context"
"sort" "sort"
"github.com/micro/go-micro/v3/errors" "github.com/unistack-org/micro/v3/errors"
"github.com/micro/go-micro/v3/router" "github.com/unistack-org/micro/v3/router"
) )
// LookupFunc is used to lookup routes for a service // LookupFunc is used to lookup routes for a service

View File

@ -1,7 +1,7 @@
package mucp package mucp
import ( import (
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
) )
var ( var (

View File

@ -8,15 +8,15 @@ import (
"time" "time"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/micro/go-micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
raw "github.com/micro/go-micro/v3/codec/bytes" raw "github.com/unistack-org/micro/v3/codec/bytes"
"github.com/micro/go-micro/v3/errors" "github.com/unistack-org/micro/v3/errors"
"github.com/micro/go-micro/v3/metadata" "github.com/unistack-org/micro/v3/metadata"
"github.com/micro/go-micro/v3/transport" "github.com/unistack-org/micro/v3/transport"
"github.com/micro/go-micro/v3/util/buf" "github.com/unistack-org/micro/v3/util/buf"
"github.com/micro/go-micro/v3/util/pool" "github.com/unistack-org/micro/v3/util/pool"
) )
type rpcClient struct { type rpcClient struct {

View File

@ -4,16 +4,16 @@ import (
"bytes" "bytes"
errs "errors" errs "errors"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
raw "github.com/micro/go-micro/v3/codec/bytes" raw "github.com/unistack-org/micro/v3/codec/bytes"
"github.com/micro/go-micro/v3/codec/grpc" "github.com/unistack-org/micro/v3/codec/grpc"
"github.com/micro/go-micro/v3/codec/json" "github.com/unistack-org/micro/v3/codec/json"
"github.com/micro/go-micro/v3/codec/jsonrpc" "github.com/unistack-org/micro/v3/codec/jsonrpc"
"github.com/micro/go-micro/v3/codec/proto" "github.com/unistack-org/micro/v3/codec/proto"
"github.com/micro/go-micro/v3/codec/protorpc" "github.com/unistack-org/micro/v3/codec/protorpc"
"github.com/micro/go-micro/v3/errors" "github.com/unistack-org/micro/v3/errors"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/micro/go-micro/v3/transport" "github.com/unistack-org/micro/v3/transport"
) )
const ( const (

View File

@ -1,7 +1,7 @@
package mucp package mucp
import ( import (
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
) )
type message struct { type message struct {

View File

@ -1,8 +1,8 @@
package mucp package mucp
import ( import (
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
) )
type rpcRequest struct { type rpcRequest struct {

View File

@ -3,7 +3,7 @@ package mucp
import ( import (
"testing" "testing"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
) )
func TestRequestOptions(t *testing.T) { func TestRequestOptions(t *testing.T) {

View File

@ -1,8 +1,8 @@
package mucp package mucp
import ( import (
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
"github.com/micro/go-micro/v3/transport" "github.com/unistack-org/micro/v3/transport"
) )
type rpcResponse struct { type rpcResponse struct {

View File

@ -5,8 +5,8 @@ import (
"io" "io"
"sync" "sync"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
) )
// Implements the streamer interface // Implements the streamer interface

View File

@ -5,12 +5,12 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
"github.com/micro/go-micro/v3/errors" "github.com/unistack-org/micro/v3/errors"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/micro/go-micro/v3/registry/memory" "github.com/unistack-org/micro/v3/registry/memory"
"github.com/micro/go-micro/v3/router" "github.com/unistack-org/micro/v3/router"
regRouter "github.com/micro/go-micro/v3/router/registry" regRouter "github.com/unistack-org/micro/v3/router/registry"
) )
func newTestRouter() router.Router { func newTestRouter() router.Router {

View File

@ -4,8 +4,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/micro/go-micro/v3/client" "github.com/unistack-org/micro/v3/client"
"github.com/micro/go-micro/v3/transport" "github.com/unistack-org/micro/v3/transport"
) )
func TestCallOptions(t *testing.T) { func TestCallOptions(t *testing.T) {

View File

@ -4,16 +4,16 @@ import (
"context" "context"
"time" "time"
"github.com/micro/go-micro/v3/broker" "github.com/unistack-org/micro/v3/broker"
"github.com/micro/go-micro/v3/broker/http" "github.com/unistack-org/micro/v3/broker/http"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
"github.com/micro/go-micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/micro/go-micro/v3/router" "github.com/unistack-org/micro/v3/router"
regRouter "github.com/micro/go-micro/v3/router/registry" regRouter "github.com/unistack-org/micro/v3/router/registry"
"github.com/micro/go-micro/v3/selector" "github.com/unistack-org/micro/v3/selector"
"github.com/micro/go-micro/v3/selector/random" "github.com/unistack-org/micro/v3/selector/random"
"github.com/micro/go-micro/v3/transport" "github.com/unistack-org/micro/v3/transport"
thttp "github.com/micro/go-micro/v3/transport/http" thttp "github.com/unistack-org/micro/v3/transport/http"
) )
type Options struct { type Options struct {

View File

@ -3,7 +3,7 @@ package client
import ( import (
"context" "context"
"github.com/micro/go-micro/v3/errors" "github.com/unistack-org/micro/v3/errors"
) )
// note that returning either false or a non-nil error will result in the call not being retried // note that returning either false or a non-nil error will result in the call not being retried

View File

@ -1,402 +1,339 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.6.1
// source: client/service/proto/client.proto // source: client/service/proto/client.proto
package go_micro_client package go_micro_client
import ( import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
codes "google.golang.org/grpc/codes" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
status "google.golang.org/grpc/status" reflect "reflect"
math "math" sync "sync"
) )
// Reference imports to suppress errors if they are not otherwise used. const (
var _ = proto.Marshal // Verify that this generated code is sufficiently up-to-date.
var _ = fmt.Errorf _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
var _ = math.Inf // Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion to ensure that this generated file // This is a compile-time assertion that a sufficiently up-to-date version
// is compatible with the proto package it is being compiled against. // of the legacy proto package is being used.
// A compilation error at this line likely means your copy of the const _ = proto.ProtoPackageIsVersion4
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type Request struct { type Request struct {
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` state protoimpl.MessageState
Endpoint string `protobuf:"bytes,2,opt,name=endpoint,proto3" json:"endpoint,omitempty"` sizeCache protoimpl.SizeCache
ContentType string `protobuf:"bytes,3,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"` unknownFields protoimpl.UnknownFields
Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
XXX_unrecognized []byte `json:"-"` Endpoint string `protobuf:"bytes,2,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
XXX_sizecache int32 `json:"-"` ContentType string `protobuf:"bytes,3,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"`
} }
func (m *Request) Reset() { *m = Request{} } func (x *Request) Reset() {
func (m *Request) String() string { return proto.CompactTextString(m) } *x = Request{}
func (*Request) ProtoMessage() {} if protoimpl.UnsafeEnabled {
mi := &file_client_service_proto_client_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Request) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Request) ProtoMessage() {}
func (x *Request) ProtoReflect() protoreflect.Message {
mi := &file_client_service_proto_client_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Request.ProtoReflect.Descriptor instead.
func (*Request) Descriptor() ([]byte, []int) { func (*Request) Descriptor() ([]byte, []int) {
return fileDescriptor_27c3d425ddd1a066, []int{0} return file_client_service_proto_client_proto_rawDescGZIP(), []int{0}
} }
func (m *Request) XXX_Unmarshal(b []byte) error { func (x *Request) GetService() string {
return xxx_messageInfo_Request.Unmarshal(m, b) if x != nil {
} return x.Service
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) GetService() string {
if m != nil {
return m.Service
} }
return "" return ""
} }
func (m *Request) GetEndpoint() string { func (x *Request) GetEndpoint() string {
if m != nil { if x != nil {
return m.Endpoint return x.Endpoint
} }
return "" return ""
} }
func (m *Request) GetContentType() string { func (x *Request) GetContentType() string {
if m != nil { if x != nil {
return m.ContentType return x.ContentType
} }
return "" return ""
} }
func (m *Request) GetBody() []byte { func (x *Request) GetBody() []byte {
if m != nil { if x != nil {
return m.Body return x.Body
} }
return nil return nil
} }
type Response struct { type Response struct {
Body []byte `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` state protoimpl.MessageState
XXX_NoUnkeyedLiteral struct{} `json:"-"` sizeCache protoimpl.SizeCache
XXX_unrecognized []byte `json:"-"` unknownFields protoimpl.UnknownFields
XXX_sizecache int32 `json:"-"`
Body []byte `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"`
} }
func (m *Response) Reset() { *m = Response{} } func (x *Response) Reset() {
func (m *Response) String() string { return proto.CompactTextString(m) } *x = Response{}
func (*Response) ProtoMessage() {} if protoimpl.UnsafeEnabled {
mi := &file_client_service_proto_client_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Response) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Response) ProtoMessage() {}
func (x *Response) ProtoReflect() protoreflect.Message {
mi := &file_client_service_proto_client_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Response.ProtoReflect.Descriptor instead.
func (*Response) Descriptor() ([]byte, []int) { func (*Response) Descriptor() ([]byte, []int) {
return fileDescriptor_27c3d425ddd1a066, []int{1} return file_client_service_proto_client_proto_rawDescGZIP(), []int{1}
} }
func (m *Response) XXX_Unmarshal(b []byte) error { func (x *Response) GetBody() []byte {
return xxx_messageInfo_Response.Unmarshal(m, b) if x != nil {
} return x.Body
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) GetBody() []byte {
if m != nil {
return m.Body
} }
return nil return nil
} }
type Message struct { type Message struct {
Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` state protoimpl.MessageState
ContentType string `protobuf:"bytes,2,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"` sizeCache protoimpl.SizeCache
Body []byte `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"` unknownFields protoimpl.UnknownFields
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`
XXX_sizecache int32 `json:"-"` ContentType string `protobuf:"bytes,2,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
Body []byte `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
} }
func (m *Message) Reset() { *m = Message{} } func (x *Message) Reset() {
func (m *Message) String() string { return proto.CompactTextString(m) } *x = Message{}
func (*Message) ProtoMessage() {} if protoimpl.UnsafeEnabled {
mi := &file_client_service_proto_client_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Message) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Message) ProtoMessage() {}
func (x *Message) ProtoReflect() protoreflect.Message {
mi := &file_client_service_proto_client_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Message.ProtoReflect.Descriptor instead.
func (*Message) Descriptor() ([]byte, []int) { func (*Message) Descriptor() ([]byte, []int) {
return fileDescriptor_27c3d425ddd1a066, []int{2} return file_client_service_proto_client_proto_rawDescGZIP(), []int{2}
} }
func (m *Message) XXX_Unmarshal(b []byte) error { func (x *Message) GetTopic() string {
return xxx_messageInfo_Message.Unmarshal(m, b) if x != nil {
} return x.Topic
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) GetTopic() string {
if m != nil {
return m.Topic
} }
return "" return ""
} }
func (m *Message) GetContentType() string { func (x *Message) GetContentType() string {
if m != nil { if x != nil {
return m.ContentType return x.ContentType
} }
return "" return ""
} }
func (m *Message) GetBody() []byte { func (x *Message) GetBody() []byte {
if m != nil { if x != nil {
return m.Body return x.Body
} }
return nil return nil
} }
func init() { var File_client_service_proto_client_proto protoreflect.FileDescriptor
proto.RegisterType((*Request)(nil), "go.micro.client.Request")
proto.RegisterType((*Response)(nil), "go.micro.client.Response") var file_client_service_proto_client_proto_rawDesc = []byte{
proto.RegisterType((*Message)(nil), "go.micro.client.Message") 0x0a, 0x21, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x63, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x22, 0x76, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64,
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64,
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e,
0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79,
0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x1e, 0x0a, 0x08,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x56, 0x0a, 0x07,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x21, 0x0a,
0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65,
0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04,
0x62, 0x6f, 0x64, 0x79, 0x32, 0xcd, 0x01, 0x0a, 0x06, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12,
0x3d, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x18, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63,
0x72, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x19, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x63, 0x6c, 0x69,
0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43,
0x0a, 0x06, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69,
0x63, 0x72, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x19, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x63, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28,
0x01, 0x30, 0x01, 0x12, 0x3f, 0x0a, 0x07, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x12, 0x18,
0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74,
0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x18, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69,
0x63, 0x72, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
func init() { proto.RegisterFile("client/service/proto/client.proto", fileDescriptor_27c3d425ddd1a066) } var (
file_client_service_proto_client_proto_rawDescOnce sync.Once
file_client_service_proto_client_proto_rawDescData = file_client_service_proto_client_proto_rawDesc
)
var fileDescriptor_27c3d425ddd1a066 = []byte{ func file_client_service_proto_client_proto_rawDescGZIP() []byte {
// 267 bytes of a gzipped FileDescriptorProto file_client_service_proto_client_proto_rawDescOnce.Do(func() {
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xc1, 0x4b, 0xc3, 0x30, file_client_service_proto_client_proto_rawDescData = protoimpl.X.CompressGZIP(file_client_service_proto_client_proto_rawDescData)
0x14, 0xc6, 0x97, 0x6d, 0xb6, 0xf3, 0x39, 0x10, 0x1e, 0x1e, 0x62, 0x0f, 0xb2, 0xf5, 0xd4, 0x53, })
0x2b, 0x7a, 0x16, 0x0f, 0x3d, 0x0b, 0x52, 0xc5, 0xab, 0xb4, 0xd9, 0x63, 0x06, 0xba, 0x24, 0x36, return file_client_service_proto_client_proto_rawDescData
0xd9, 0xa0, 0x7f, 0xa4, 0xff, 0x93, 0x90, 0x46, 0x27, 0xba, 0x5d, 0xbc, 0xe5, 0xfb, 0x7e, 0xe4,
0x7b, 0x2f, 0x5f, 0x60, 0x29, 0x5a, 0x49, 0xca, 0x15, 0x96, 0xba, 0x9d, 0x14, 0x54, 0x98, 0x4e,
0x3b, 0x5d, 0x0c, 0x66, 0xee, 0x05, 0x9e, 0xaf, 0x75, 0xbe, 0x91, 0xa2, 0xd3, 0xf9, 0x60, 0xa7,
0x3b, 0x88, 0x2b, 0x7a, 0xdf, 0x92, 0x75, 0xc8, 0x21, 0x0e, 0x37, 0x39, 0x5b, 0xb0, 0xec, 0xb4,
0xfa, 0x92, 0x98, 0xc0, 0x8c, 0xd4, 0xca, 0x68, 0xa9, 0x1c, 0x1f, 0x7b, 0xf4, 0xad, 0x71, 0x09,
0x73, 0xa1, 0x95, 0x23, 0xe5, 0x5e, 0x5d, 0x6f, 0x88, 0x4f, 0x3c, 0x3f, 0x0b, 0xde, 0x73, 0x6f,
0x08, 0x11, 0xa6, 0x8d, 0x5e, 0xf5, 0x7c, 0xba, 0x60, 0xd9, 0xbc, 0xf2, 0xe7, 0xf4, 0x0a, 0x66,
0x15, 0x59, 0xa3, 0x95, 0xdd, 0x73, 0xf6, 0x83, 0xbf, 0x40, 0xfc, 0x40, 0xd6, 0xd6, 0x6b, 0xc2,
0x0b, 0x38, 0x71, 0xda, 0x48, 0x11, 0xb6, 0x1a, 0xc4, 0x9f, 0xb9, 0xe3, 0xe3, 0x73, 0x27, 0xfb,
0xdc, 0x9b, 0x0f, 0x06, 0x51, 0xe9, 0x9f, 0x8e, 0x77, 0x30, 0x2d, 0xeb, 0xb6, 0x45, 0x9e, 0xff,
0x2a, 0x25, 0x0f, 0x8d, 0x24, 0x97, 0x07, 0xc8, 0xb0, 0x73, 0x3a, 0xc2, 0x12, 0xa2, 0x27, 0xd7,
0x51, 0xbd, 0xf9, 0x67, 0x40, 0xc6, 0xae, 0x19, 0xde, 0x43, 0xfc, 0xb8, 0x6d, 0x5a, 0x69, 0xdf,
0x0e, 0xa4, 0x84, 0x02, 0x92, 0xa3, 0x24, 0x1d, 0x35, 0x91, 0xff, 0xd7, 0xdb, 0xcf, 0x00, 0x00,
0x00, 0xff, 0xff, 0xd6, 0x3f, 0xc3, 0xa1, 0xfc, 0x01, 0x00, 0x00,
} }
// Reference imports to suppress errors if they are not otherwise used. var file_client_service_proto_client_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var _ context.Context var file_client_service_proto_client_proto_goTypes = []interface{}{
var _ grpc.ClientConn (*Request)(nil), // 0: go.micro.client.Request
(*Response)(nil), // 1: go.micro.client.Response
// This is a compile-time assertion to ensure that this generated file (*Message)(nil), // 2: go.micro.client.Message
// is compatible with the grpc package it is being compiled against. }
const _ = grpc.SupportPackageIsVersion4 var file_client_service_proto_client_proto_depIdxs = []int32{
0, // 0: go.micro.client.Client.Call:input_type -> go.micro.client.Request
// ClientClient is the client API for Client service. 0, // 1: go.micro.client.Client.Stream:input_type -> go.micro.client.Request
// 2, // 2: go.micro.client.Client.Publish:input_type -> go.micro.client.Message
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. 1, // 3: go.micro.client.Client.Call:output_type -> go.micro.client.Response
type ClientClient interface { 1, // 4: go.micro.client.Client.Stream:output_type -> go.micro.client.Response
// Call allows a single request to be made 2, // 5: go.micro.client.Client.Publish:output_type -> go.micro.client.Message
Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) 3, // [3:6] is the sub-list for method output_type
// Stream is a bidirectional stream 0, // [0:3] is the sub-list for method input_type
Stream(ctx context.Context, opts ...grpc.CallOption) (Client_StreamClient, error) 0, // [0:0] is the sub-list for extension type_name
// Publish publishes a message and returns an empty Message 0, // [0:0] is the sub-list for extension extendee
Publish(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Message, error) 0, // [0:0] is the sub-list for field type_name
} }
type clientClient struct { func init() { file_client_service_proto_client_proto_init() }
cc *grpc.ClientConn func file_client_service_proto_client_proto_init() {
} if File_client_service_proto_client_proto != nil {
return
func NewClientClient(cc *grpc.ClientConn) ClientClient {
return &clientClient{cc}
}
func (c *clientClient) Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
out := new(Response)
err := c.cc.Invoke(ctx, "/go.micro.client.Client/Call", in, out, opts...)
if err != nil {
return nil, err
} }
return out, nil if !protoimpl.UnsafeEnabled {
} file_client_service_proto_client_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Request); i {
func (c *clientClient) Stream(ctx context.Context, opts ...grpc.CallOption) (Client_StreamClient, error) { case 0:
stream, err := c.cc.NewStream(ctx, &_Client_serviceDesc.Streams[0], "/go.micro.client.Client/Stream", opts...) return &v.state
if err != nil { case 1:
return nil, err return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_client_service_proto_client_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Response); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_client_service_proto_client_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Message); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
x := &clientStreamClient{stream} type x struct{}
return x, nil out := protoimpl.TypeBuilder{
} File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
type Client_StreamClient interface { RawDescriptor: file_client_service_proto_client_proto_rawDesc,
Send(*Request) error NumEnums: 0,
Recv() (*Response, error) NumMessages: 3,
grpc.ClientStream NumExtensions: 0,
} NumServices: 1,
type clientStreamClient struct {
grpc.ClientStream
}
func (x *clientStreamClient) Send(m *Request) error {
return x.ClientStream.SendMsg(m)
}
func (x *clientStreamClient) Recv() (*Response, error) {
m := new(Response)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *clientClient) Publish(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Message, error) {
out := new(Message)
err := c.cc.Invoke(ctx, "/go.micro.client.Client/Publish", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ClientServer is the server API for Client service.
type ClientServer interface {
// Call allows a single request to be made
Call(context.Context, *Request) (*Response, error)
// Stream is a bidirectional stream
Stream(Client_StreamServer) error
// Publish publishes a message and returns an empty Message
Publish(context.Context, *Message) (*Message, error)
}
// UnimplementedClientServer can be embedded to have forward compatible implementations.
type UnimplementedClientServer struct {
}
func (*UnimplementedClientServer) Call(ctx context.Context, req *Request) (*Response, error) {
return nil, status.Errorf(codes.Unimplemented, "method Call not implemented")
}
func (*UnimplementedClientServer) Stream(srv Client_StreamServer) error {
return status.Errorf(codes.Unimplemented, "method Stream not implemented")
}
func (*UnimplementedClientServer) Publish(ctx context.Context, req *Message) (*Message, error) {
return nil, status.Errorf(codes.Unimplemented, "method Publish not implemented")
}
func RegisterClientServer(s *grpc.Server, srv ClientServer) {
s.RegisterService(&_Client_serviceDesc, srv)
}
func _Client_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Request)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ClientServer).Call(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/go.micro.client.Client/Call",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ClientServer).Call(ctx, req.(*Request))
}
return interceptor(ctx, in, info, handler)
}
func _Client_Stream_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(ClientServer).Stream(&clientStreamServer{stream})
}
type Client_StreamServer interface {
Send(*Response) error
Recv() (*Request, error)
grpc.ServerStream
}
type clientStreamServer struct {
grpc.ServerStream
}
func (x *clientStreamServer) Send(m *Response) error {
return x.ServerStream.SendMsg(m)
}
func (x *clientStreamServer) Recv() (*Request, error) {
m := new(Request)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func _Client_Publish_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Message)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ClientServer).Publish(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/go.micro.client.Client/Publish",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ClientServer).Publish(ctx, req.(*Message))
}
return interceptor(ctx, in, info, handler)
}
var _Client_serviceDesc = grpc.ServiceDesc{
ServiceName: "go.micro.client.Client",
HandlerType: (*ClientServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Call",
Handler: _Client_Call_Handler,
}, },
{ GoTypes: file_client_service_proto_client_proto_goTypes,
MethodName: "Publish", DependencyIndexes: file_client_service_proto_client_proto_depIdxs,
Handler: _Client_Publish_Handler, MessageInfos: file_client_service_proto_client_proto_msgTypes,
}, }.Build()
}, File_client_service_proto_client_proto = out.File
Streams: []grpc.StreamDesc{ file_client_service_proto_client_proto_rawDesc = nil
{ file_client_service_proto_client_proto_goTypes = nil
StreamName: "Stream", file_client_service_proto_client_proto_depIdxs = nil
Handler: _Client_Stream_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "client/service/proto/client.proto",
} }

View File

@ -11,9 +11,9 @@ import (
import ( import (
context "context" context "context"
api "github.com/micro/go-micro/v3/api" api "github.com/unistack-org/micro/v3/api"
client "github.com/micro/go-micro/v3/client" client "github.com/unistack-org/micro/v3/client"
server "github.com/micro/go-micro/v3/server" server "github.com/unistack-org/micro/v3/server"
) )
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.

View File

@ -0,0 +1,201 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package go_micro_client
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// ClientClient is the client API for Client 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.
type ClientClient interface {
// Call allows a single request to be made
Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
// Stream is a bidirectional stream
Stream(ctx context.Context, opts ...grpc.CallOption) (Client_StreamClient, error)
// Publish publishes a message and returns an empty Message
Publish(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Message, error)
}
type clientClient struct {
cc grpc.ClientConnInterface
}
func NewClientClient(cc grpc.ClientConnInterface) ClientClient {
return &clientClient{cc}
}
func (c *clientClient) Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
out := new(Response)
err := c.cc.Invoke(ctx, "/go.micro.client.Client/Call", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *clientClient) Stream(ctx context.Context, opts ...grpc.CallOption) (Client_StreamClient, error) {
stream, err := c.cc.NewStream(ctx, &_Client_serviceDesc.Streams[0], "/go.micro.client.Client/Stream", opts...)
if err != nil {
return nil, err
}
x := &clientStreamClient{stream}
return x, nil
}
type Client_StreamClient interface {
Send(*Request) error
Recv() (*Response, error)
grpc.ClientStream
}
type clientStreamClient struct {
grpc.ClientStream
}
func (x *clientStreamClient) Send(m *Request) error {
return x.ClientStream.SendMsg(m)
}
func (x *clientStreamClient) Recv() (*Response, error) {
m := new(Response)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *clientClient) Publish(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Message, error) {
out := new(Message)
err := c.cc.Invoke(ctx, "/go.micro.client.Client/Publish", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ClientServer is the server API for Client service.
// All implementations must embed UnimplementedClientServer
// for forward compatibility
type ClientServer interface {
// Call allows a single request to be made
Call(context.Context, *Request) (*Response, error)
// Stream is a bidirectional stream
Stream(Client_StreamServer) error
// Publish publishes a message and returns an empty Message
Publish(context.Context, *Message) (*Message, error)
mustEmbedUnimplementedClientServer()
}
// UnimplementedClientServer must be embedded to have forward compatible implementations.
type UnimplementedClientServer struct {
}
func (*UnimplementedClientServer) Call(context.Context, *Request) (*Response, error) {
return nil, status.Errorf(codes.Unimplemented, "method Call not implemented")
}
func (*UnimplementedClientServer) Stream(Client_StreamServer) error {
return status.Errorf(codes.Unimplemented, "method Stream not implemented")
}
func (*UnimplementedClientServer) Publish(context.Context, *Message) (*Message, error) {
return nil, status.Errorf(codes.Unimplemented, "method Publish not implemented")
}
func (*UnimplementedClientServer) mustEmbedUnimplementedClientServer() {}
func RegisterClientServer(s *grpc.Server, srv ClientServer) {
s.RegisterService(&_Client_serviceDesc, srv)
}
func _Client_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Request)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ClientServer).Call(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/go.micro.client.Client/Call",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ClientServer).Call(ctx, req.(*Request))
}
return interceptor(ctx, in, info, handler)
}
func _Client_Stream_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(ClientServer).Stream(&clientStreamServer{stream})
}
type Client_StreamServer interface {
Send(*Response) error
Recv() (*Request, error)
grpc.ServerStream
}
type clientStreamServer struct {
grpc.ServerStream
}
func (x *clientStreamServer) Send(m *Response) error {
return x.ServerStream.SendMsg(m)
}
func (x *clientStreamServer) Recv() (*Request, error) {
m := new(Request)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func _Client_Publish_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Message)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ClientServer).Publish(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/go.micro.client.Client/Publish",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ClientServer).Publish(ctx, req.(*Message))
}
return interceptor(ctx, in, info, handler)
}
var _Client_serviceDesc = grpc.ServiceDesc{
ServiceName: "go.micro.client.Client",
HandlerType: (*ClientServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Call",
Handler: _Client_Call_Handler,
},
{
MethodName: "Publish",
Handler: _Client_Publish_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "Stream",
Handler: _Client_Stream_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "client/service/proto/client.proto",
}

View File

@ -1,7 +1,7 @@
package client package client
import ( import (
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
) )
type testRequest struct { type testRequest struct {

33
cmd/protoc-gen-micro/.gitignore vendored Normal file
View File

@ -0,0 +1,33 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
_build
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof
# ignore go build and test outputs
coverage.txt
coverage.out
# ignore locally built binaries
protoc-gen-micro
dist

View File

@ -0,0 +1,138 @@
# protoc-gen-micro
This is protobuf code generation for micro. We use protoc-gen-micro to reduce boilerplate code.
## Install
```
go get github.com/micro/micro/v3/cmd/protoc-gen-micro@master
```
Also required:
- [protoc](https://github.com/google/protobuf)
- [protoc-gen-go](https://github.com/golang/protobuf)
## Usage
Define your service as `greeter.proto`
```
syntax = "proto3";
service Greeter {
rpc Hello(Request) returns (Response) {}
}
message Request {
string name = 1;
}
message Response {
string msg = 1;
}
```
Generate the code
```
protoc --proto_path=$GOPATH/src:. --micro_out=. --go_out=. greeter.proto
```
Your output result should be:
```
./
greeter.proto # original protobuf file
greeter.pb.go # auto-generated by protoc-gen-go
greeter.micro.go # auto-generated by protoc-gen-micro
```
The micro generated code includes clients and handlers which reduce boiler plate code
### Server
Register the handler with your micro server
```go
type Greeter struct{}
func (g *Greeter) Hello(ctx context.Context, req *proto.Request, rsp *proto.Response) error {
rsp.Msg = "Hello " + req.Name
return nil
}
proto.RegisterGreeterHandler(service.Server(), &Greeter{})
```
### Client
Create a service client with your micro client
```go
client := proto.NewGreeterService("greeter", service.Client())
```
### Errors
If you see an error about `protoc-gen-micro` not being found or executable, it's likely your environment may not be configured correctly. If you've already installed `protoc`, `protoc-gen-go`, and `protoc-gen-micro` ensure you've included `$GOPATH/bin` in your `PATH`.
Alternative specify the Go plugin paths as arguments to the `protoc` command
```
protoc --plugin=protoc-gen-go=$GOPATH/bin/protoc-gen-go --plugin=protoc-gen-micro=$GOPATH/bin/protoc-gen-micro --proto_path=$GOPATH/src:. --micro_out=. --go_out=. greeter.proto
```
### Endpoint
Add a micro API endpoint which routes directly to an RPC method
Usage:
1. Clone `github.com/googleapis/googleapis` to use this feature as it requires http annotations.
2. The protoc command must include `-I$GOPATH/src/github.com/googleapis/googleapis` for the annotations import.
```diff
syntax = "proto3";
import "google/api/annotations.proto";
service Greeter {
rpc Hello(Request) returns (Response) {
option (google.api.http) = { post: "/hello"; body: "*"; };
}
}
message Request {
string name = 1;
}
message Response {
string msg = 1;
}
```
The proto generates a `RegisterGreeterHandler` function with a [api.Endpoint](https://godoc.org/github.com/micro/go-micro/api#Endpoint).
```diff
func RegisterGreeterHandler(s server.Server, hdlr GreeterHandler, opts ...server.HandlerOption) error {
type greeter interface {
Hello(ctx context.Context, in *Request, out *Response) error
}
type Greeter struct {
greeter
}
h := &greeterHandler{hdlr}
opts = append(opts, api.WithEndpoint(&api.Endpoint{
Name: "Greeter.Hello",
Path: []string{"/hello"},
Method: []string{"POST"},
Handler: "rpc",
}))
return s.Handle(s.NewHandler(&Greeter{h}, opts...))
}
```
## LICENSE
protoc-gen-micro is a liberal reuse of protoc-gen-go hence we maintain the original license

View File

@ -0,0 +1,223 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.6.1
// source: cmd/protoc-gen-micro/examples/greeter/greeter.proto
package greeter
import (
proto "github.com/golang/protobuf/proto"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type Request struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}
func (x *Request) Reset() {
*x = Request{}
if protoimpl.UnsafeEnabled {
mi := &file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Request) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Request) ProtoMessage() {}
func (x *Request) ProtoReflect() protoreflect.Message {
mi := &file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Request.ProtoReflect.Descriptor instead.
func (*Request) Descriptor() ([]byte, []int) {
return file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDescGZIP(), []int{0}
}
func (x *Request) GetName() string {
if x != nil {
return x.Name
}
return ""
}
type Response struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
}
func (x *Response) Reset() {
*x = Response{}
if protoimpl.UnsafeEnabled {
mi := &file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Response) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Response) ProtoMessage() {}
func (x *Response) ProtoReflect() protoreflect.Message {
mi := &file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Response.ProtoReflect.Descriptor instead.
func (*Response) Descriptor() ([]byte, []int) {
return file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDescGZIP(), []int{1}
}
func (x *Response) GetMsg() string {
if x != nil {
return x.Msg
}
return ""
}
var File_cmd_protoc_gen_micro_examples_greeter_greeter_proto protoreflect.FileDescriptor
var file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDesc = []byte{
0x0a, 0x33, 0x63, 0x6d, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e,
0x2d, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f,
0x67, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x2f, 0x67, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70,
0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x22, 0x1d, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12,
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x22, 0x1c, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10,
0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67,
0x32, 0x6e, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x12, 0x2f, 0x0a, 0x05, 0x48,
0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x08, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x09,
0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02,
0x0b, 0x22, 0x06, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x3a, 0x01, 0x2a, 0x12, 0x32, 0x0a, 0x06,
0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x08, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x09, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0f, 0x82, 0xd3, 0xe4,
0x93, 0x02, 0x09, 0x12, 0x07, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x28, 0x01, 0x30, 0x01,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDescOnce sync.Once
file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDescData = file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDesc
)
func file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDescGZIP() []byte {
file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDescOnce.Do(func() {
file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDescData = protoimpl.X.CompressGZIP(file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDescData)
})
return file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDescData
}
var file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_goTypes = []interface{}{
(*Request)(nil), // 0: Request
(*Response)(nil), // 1: Response
}
var file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_depIdxs = []int32{
0, // 0: Greeter.Hello:input_type -> Request
0, // 1: Greeter.Stream:input_type -> Request
1, // 2: Greeter.Hello:output_type -> Response
1, // 3: Greeter.Stream:output_type -> Response
2, // [2:4] is the sub-list for method output_type
0, // [0:2] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_init() }
func file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_init() {
if File_cmd_protoc_gen_micro_examples_greeter_greeter_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Request); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Response); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_goTypes,
DependencyIndexes: file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_depIdxs,
MessageInfos: file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_msgTypes,
}.Build()
File_cmd_protoc_gen_micro_examples_greeter_greeter_proto = out.File
file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_rawDesc = nil
file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_goTypes = nil
file_cmd_protoc_gen_micro_examples_greeter_greeter_proto_depIdxs = nil
}

View File

@ -0,0 +1,222 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: cmd/protoc-gen-micro/examples/greeter/greeter.proto
package greeter
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
_ "google.golang.org/genproto/googleapis/api/annotations"
math "math"
)
import (
context "context"
api "github.com/unistack-org/micro/v3/api"
client "github.com/unistack-org/micro/v3/client"
server "github.com/unistack-org/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 Greeter service
func NewGreeterEndpoints() []*api.Endpoint {
return []*api.Endpoint{
&api.Endpoint{
Name: "Greeter.Hello",
Path: []string{"/hello"},
Method: []string{"POST"},
Body: "*",
Handler: "rpc",
},
&api.Endpoint{
Name: "Greeter.Stream",
Path: []string{"/stream"},
Method: []string{"GET"},
Stream: true,
Handler: "rpc",
},
}
}
// 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}
opts = append(opts, api.WithEndpoint(&api.Endpoint{
Name: "Greeter.Hello",
Path: []string{"/hello"},
Method: []string{"POST"},
Body: "*",
Handler: "rpc",
}))
opts = append(opts, api.WithEndpoint(&api.Endpoint{
Name: "Greeter.Stream",
Path: []string{"/stream"},
Method: []string{"GET"},
Stream: true,
Handler: "rpc",
}))
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
}

View File

@ -0,0 +1,20 @@
syntax = "proto3";
import "google/api/annotations.proto";
service Greeter {
rpc Hello(Request) returns (Response) {
option (google.api.http) = { post: "/hello"; body: "*"; };
}
rpc Stream(stream Request) returns (stream Response) {
option (google.api.http) = { get: "/stream"; };
}
}
message Request {
string name = 1;
}
message Response {
string msg = 1;
}

View File

@ -0,0 +1,159 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package greeter
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// GreeterClient is the client API for Greeter 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.
type GreeterClient interface {
Hello(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
Stream(ctx context.Context, opts ...grpc.CallOption) (Greeter_StreamClient, error)
}
type greeterClient struct {
cc grpc.ClientConnInterface
}
func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient {
return &greeterClient{cc}
}
func (c *greeterClient) Hello(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
out := new(Response)
err := c.cc.Invoke(ctx, "/Greeter/Hello", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *greeterClient) Stream(ctx context.Context, opts ...grpc.CallOption) (Greeter_StreamClient, error) {
stream, err := c.cc.NewStream(ctx, &_Greeter_serviceDesc.Streams[0], "/Greeter/Stream", opts...)
if err != nil {
return nil, err
}
x := &greeterStreamClient{stream}
return x, nil
}
type Greeter_StreamClient interface {
Send(*Request) error
Recv() (*Response, error)
grpc.ClientStream
}
type greeterStreamClient struct {
grpc.ClientStream
}
func (x *greeterStreamClient) Send(m *Request) error {
return x.ClientStream.SendMsg(m)
}
func (x *greeterStreamClient) Recv() (*Response, error) {
m := new(Response)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// GreeterServer is the server API for Greeter service.
// All implementations must embed UnimplementedGreeterServer
// for forward compatibility
type GreeterServer interface {
Hello(context.Context, *Request) (*Response, error)
Stream(Greeter_StreamServer) error
mustEmbedUnimplementedGreeterServer()
}
// UnimplementedGreeterServer must be embedded to have forward compatible implementations.
type UnimplementedGreeterServer struct {
}
func (*UnimplementedGreeterServer) Hello(context.Context, *Request) (*Response, error) {
return nil, status.Errorf(codes.Unimplemented, "method Hello not implemented")
}
func (*UnimplementedGreeterServer) Stream(Greeter_StreamServer) error {
return status.Errorf(codes.Unimplemented, "method Stream not implemented")
}
func (*UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {}
func RegisterGreeterServer(s *grpc.Server, srv GreeterServer) {
s.RegisterService(&_Greeter_serviceDesc, srv)
}
func _Greeter_Hello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Request)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GreeterServer).Hello(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Greeter/Hello",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GreeterServer).Hello(ctx, req.(*Request))
}
return interceptor(ctx, in, info, handler)
}
func _Greeter_Stream_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(GreeterServer).Stream(&greeterStreamServer{stream})
}
type Greeter_StreamServer interface {
Send(*Response) error
Recv() (*Request, error)
grpc.ServerStream
}
type greeterStreamServer struct {
grpc.ServerStream
}
func (x *greeterStreamServer) Send(m *Response) error {
return x.ServerStream.SendMsg(m)
}
func (x *greeterStreamServer) Recv() (*Request, error) {
m := new(Request)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
var _Greeter_serviceDesc = grpc.ServiceDesc{
ServiceName: "Greeter",
HandlerType: (*GreeterServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Hello",
Handler: _Greeter_Hello_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "Stream",
Handler: _Greeter_Stream_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "cmd/protoc-gen-micro/examples/greeter/greeter.proto",
}

View File

@ -0,0 +1,40 @@
# Go support for Protocol Buffers - Google's data interchange format
#
# Copyright 2010 The Go Authors. All rights reserved.
# https://github.com/golang/protobuf
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include $(GOROOT)/src/Make.inc
TARG=github.com/golang/protobuf/compiler/generator
GOFILES=\
generator.go\
DEPS=../descriptor ../plugin ../../proto
include $(GOROOT)/src/Make.pkg

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,135 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2013 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package generator
import (
"testing"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
)
func TestCamelCase(t *testing.T) {
tests := []struct {
in, want string
}{
{"one", "One"},
{"one_two", "OneTwo"},
{"_my_field_name_2", "XMyFieldName_2"},
{"Something_Capped", "Something_Capped"},
{"my_Name", "My_Name"},
{"OneTwo", "OneTwo"},
{"_", "X"},
{"_a_", "XA_"},
}
for _, tc := range tests {
if got := CamelCase(tc.in); got != tc.want {
t.Errorf("CamelCase(%q) = %q, want %q", tc.in, got, tc.want)
}
}
}
func TestGoPackageOption(t *testing.T) {
tests := []struct {
in string
impPath GoImportPath
pkg GoPackageName
ok bool
}{
{"", "", "", false},
{"foo", "", "foo", true},
{"github.com/golang/bar", "github.com/golang/bar", "bar", true},
{"github.com/golang/bar;baz", "github.com/golang/bar", "baz", true},
{"github.com/golang/string", "github.com/golang/string", "string", true},
}
for _, tc := range tests {
d := &FileDescriptor{
FileDescriptorProto: &descriptor.FileDescriptorProto{
Options: &descriptor.FileOptions{
GoPackage: &tc.in,
},
},
}
impPath, pkg, ok := d.goPackageOption()
if impPath != tc.impPath || pkg != tc.pkg || ok != tc.ok {
t.Errorf("go_package = %q => (%q, %q, %t), want (%q, %q, %t)", tc.in,
impPath, pkg, ok, tc.impPath, tc.pkg, tc.ok)
}
}
}
func TestPackageNames(t *testing.T) {
g := New()
g.packageNames = make(map[GoImportPath]GoPackageName)
g.usedPackageNames = make(map[GoPackageName]bool)
for _, test := range []struct {
importPath GoImportPath
want GoPackageName
}{
{"github.com/golang/foo", "foo"},
{"github.com/golang/second/package/named/foo", "foo1"},
{"github.com/golang/third/package/named/foo", "foo2"},
{"github.com/golang/conflicts/with/predeclared/ident/string", "string1"},
} {
if got := g.GoPackageName(test.importPath); got != test.want {
t.Errorf("GoPackageName(%v) = %v, want %v", test.importPath, got, test.want)
}
}
}
func TestUnescape(t *testing.T) {
tests := []struct {
in string
out string
}{
// successful cases, including all kinds of escapes
{"", ""},
{"foo bar baz frob nitz", "foo bar baz frob nitz"},
{`\000\001\002\003\004\005\006\007`, string([]byte{0, 1, 2, 3, 4, 5, 6, 7})},
{`\a\b\f\n\r\t\v\\\?\'\"`, string([]byte{'\a', '\b', '\f', '\n', '\r', '\t', '\v', '\\', '?', '\'', '"'})},
{`\x10\x20\x30\x40\x50\x60\x70\x80`, string([]byte{16, 32, 48, 64, 80, 96, 112, 128})},
// variable length octal escapes
{`\0\018\222\377\3\04\005\6\07`, string([]byte{0, 1, '8', 0222, 255, 3, 4, 5, 6, 7})},
// malformed escape sequences left as is
{"foo \\g bar", "foo \\g bar"},
{"foo \\xg0 bar", "foo \\xg0 bar"},
{"\\", "\\"},
{"\\x", "\\x"},
{"\\xf", "\\xf"},
{"\\777", "\\777"}, // overflows byte
}
for _, tc := range tests {
s := unescape(tc.in)
if s != tc.out {
t.Errorf("doUnescape(%q) = %q; should have been %q", tc.in, s, tc.out)
}
}
}

View File

@ -0,0 +1,99 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// protoc-gen-micro is a plugin for the Google protocol buffer compiler to generate
// Go code. Run it by building this program and putting it in your path with
// the name
// protoc-gen-micro
// That word 'micro' at the end becomes part of the option string set for the
// protocol compiler, so once the protocol compiler (protoc) is installed
// you can run
// protoc --micro_out=output_directory --go_out=output_directory input_directory/file.proto
// to generate go-micro code for the protocol defined by file.proto.
// With that input, the output will be written to
// output_directory/file.micro.go
//
// The generated code is documented in the package comment for
// the library.
//
// See the README and documentation for protocol buffers to learn more:
// https://developers.google.com/protocol-buffers/
package main
import (
"io/ioutil"
"os"
"github.com/golang/protobuf/proto"
"github.com/unistack-org/micro/v3/cmd/protoc-gen-micro/generator"
_ "github.com/unistack-org/micro/v3/cmd/protoc-gen-micro/plugin/micro"
)
func main() {
// Begin by allocating a generator. The request and response structures are stored there
// so we can do error handling easily - the response structure contains the field to
// report failure.
g := generator.New()
data, err := ioutil.ReadAll(os.Stdin)
if err != nil {
g.Error(err, "reading input")
}
if err := proto.Unmarshal(data, g.Request); err != nil {
g.Error(err, "parsing input proto")
}
if len(g.Request.FileToGenerate) == 0 {
g.Fail("no files to generate")
}
g.CommandLineParameters(g.Request.GetParameter())
// Create a wrapped version of the Descriptors and EnumDescriptors that
// point to the file that defines them.
g.WrapTypes()
g.SetPackageNames()
g.BuildTypeNameMap()
g.GenerateAllFiles()
// Send back the results.
data, err = proto.Marshal(g.Response)
if err != nil {
g.Error(err, "failed to marshal output proto")
}
_, err = os.Stdout.Write(data)
if err != nil {
g.Error(err, "failed to write output proto")
}
}

View File

@ -0,0 +1,553 @@
package micro
import (
"fmt"
"path"
"strconv"
"strings"
"github.com/golang/protobuf/proto"
pb "github.com/golang/protobuf/protoc-gen-go/descriptor"
"github.com/unistack-org/micro/v3/cmd/protoc-gen-micro/generator"
options "google.golang.org/genproto/googleapis/api/annotations"
)
// Paths for packages used by code generated in this file,
// relative to the import_prefix of the generator.Generator.
const (
apiPkgPath = "github.com/unistack-org/micro/v3/api"
contextPkgPath = "context"
clientPkgPath = "github.com/unistack-org/micro/v3/client"
serverPkgPath = "github.com/unistack-org/micro/v3/server"
)
func init() {
generator.RegisterPlugin(new(micro))
}
// micro is an implementation of the Go protocol buffer compiler's
// plugin architecture. It generates bindings for go-micro support.
type micro struct {
gen *generator.Generator
}
// Name returns the name of this plugin, "micro".
func (g *micro) Name() string {
return "micro"
}
// The names for packages imported in the generated code.
// They may vary from the final path component of the import path
// if the name is used by other packages.
var (
apiPkg string
contextPkg string
clientPkg string
serverPkg string
pkgImports map[generator.GoPackageName]bool
)
// Init initializes the plugin.
func (g *micro) Init(gen *generator.Generator) {
g.gen = gen
apiPkg = generator.RegisterUniquePackageName("api", nil)
contextPkg = generator.RegisterUniquePackageName("context", nil)
clientPkg = generator.RegisterUniquePackageName("client", nil)
serverPkg = generator.RegisterUniquePackageName("server", nil)
}
// Given a type name defined in a .proto, return its object.
// Also record that we're using it, to guarantee the associated import.
func (g *micro) objectNamed(name string) generator.Object {
g.gen.RecordTypeUse(name)
return g.gen.ObjectNamed(name)
}
// Given a type name defined in a .proto, return its name as we will print it.
func (g *micro) typeName(str string) string {
return g.gen.TypeName(g.objectNamed(str))
}
// P forwards to g.gen.P.
func (g *micro) P(args ...interface{}) { g.gen.P(args...) }
// Generate generates code for the services in the given file.
func (g *micro) Generate(file *generator.FileDescriptor) {
if len(file.FileDescriptorProto.Service) == 0 {
return
}
g.P("// Reference imports to suppress errors if they are not otherwise used.")
g.P("var _ ", apiPkg, ".Endpoint")
g.P("var _ ", contextPkg, ".Context")
g.P("var _ ", clientPkg, ".Option")
g.P("var _ ", serverPkg, ".Option")
g.P()
for i, service := range file.FileDescriptorProto.Service {
g.generateService(file, service, i)
}
}
// GenerateImports generates the import declaration for this file.
func (g *micro) GenerateImports(file *generator.FileDescriptor, imports map[generator.GoImportPath]generator.GoPackageName) {
if len(file.FileDescriptorProto.Service) == 0 {
return
}
g.P("import (")
g.P(apiPkg, " ", strconv.Quote(path.Join(g.gen.ImportPrefix, apiPkgPath)))
g.P(contextPkg, " ", strconv.Quote(path.Join(g.gen.ImportPrefix, contextPkgPath)))
g.P(clientPkg, " ", strconv.Quote(path.Join(g.gen.ImportPrefix, clientPkgPath)))
g.P(serverPkg, " ", strconv.Quote(path.Join(g.gen.ImportPrefix, serverPkgPath)))
g.P(")")
g.P()
// We need to keep track of imported packages to make sure we don't produce
// a name collision when generating types.
pkgImports = make(map[generator.GoPackageName]bool)
for _, name := range imports {
pkgImports[name] = true
}
}
// reservedClientName records whether a client name is reserved on the client side.
var reservedClientName = map[string]bool{
// TODO: do we need any in go-micro?
}
func unexport(s string) string {
if len(s) == 0 {
return ""
}
name := strings.ToLower(s[:1]) + s[1:]
if pkgImports[generator.GoPackageName(name)] {
return name + "_"
}
return name
}
// generateService generates all the code for the named service.
func (g *micro) generateService(file *generator.FileDescriptor, service *pb.ServiceDescriptorProto, index int) {
path := fmt.Sprintf("6,%d", index) // 6 means service.
origServName := service.GetName()
serviceName := strings.ToLower(service.GetName())
if pkg := file.GetPackage(); pkg != "" {
serviceName = pkg
}
servName := generator.CamelCase(origServName)
servAlias := servName + "Service"
// strip suffix
if strings.HasSuffix(servAlias, "ServiceService") {
servAlias = strings.TrimSuffix(servAlias, "Service")
}
g.P()
g.P("// Api Endpoints for ", servName, " service")
g.P()
g.P("func New", servName, "Endpoints () []*", apiPkg, ".Endpoint {")
g.P("return []*", apiPkg, ".Endpoint{")
for _, method := range service.Method {
if method.Options != nil && proto.HasExtension(method.Options, options.E_Http) {
g.P("&", apiPkg, ".Endpoint{")
g.generateEndpoint(servName, method)
g.P("},")
}
}
g.P("}")
g.P("}")
g.P()
g.P()
g.P("// Client API for ", servName, " service")
g.P()
// Client interface.
g.P("type ", servAlias, " interface {")
for i, method := range service.Method {
g.gen.PrintComments(fmt.Sprintf("%s,2,%d", path, i)) // 2 means method in a service.
g.P(g.generateClientSignature(servName, method))
}
g.P("}")
g.P()
// Client structure.
g.P("type ", unexport(servAlias), " struct {")
g.P("c ", clientPkg, ".Client")
g.P("name string")
g.P("}")
g.P()
// NewClient factory.
g.P("func New", servAlias, " (name string, c ", clientPkg, ".Client) ", servAlias, " {")
/*
g.P("if c == nil {")
g.P("c = ", clientPkg, ".NewClient()")
g.P("}")
g.P("if len(name) == 0 {")
g.P(`name = "`, serviceName, `"`)
g.P("}")
*/
g.P("return &", unexport(servAlias), "{")
g.P("c: c,")
g.P("name: name,")
g.P("}")
g.P("}")
g.P()
var methodIndex, streamIndex int
serviceDescVar := "_" + servName + "_serviceDesc"
// Client method implementations.
for _, method := range service.Method {
var descExpr string
if !method.GetServerStreaming() {
// Unary RPC method
descExpr = fmt.Sprintf("&%s.Methods[%d]", serviceDescVar, methodIndex)
methodIndex++
} else {
// Streaming RPC method
descExpr = fmt.Sprintf("&%s.Streams[%d]", serviceDescVar, streamIndex)
streamIndex++
}
g.generateClientMethod(serviceName, servName, serviceDescVar, method, descExpr)
}
g.P("// Server API for ", servName, " service")
g.P()
// Server interface.
serverType := servName + "Handler"
g.P("type ", serverType, " interface {")
for i, method := range service.Method {
g.gen.PrintComments(fmt.Sprintf("%s,2,%d", path, i)) // 2 means method in a service.
g.P(g.generateServerSignature(servName, method))
}
g.P("}")
g.P()
// Server registration.
g.P("func Register", servName, "Handler(s ", serverPkg, ".Server, hdlr ", serverType, ", opts ...", serverPkg, ".HandlerOption) error {")
g.P("type ", unexport(servName), " interface {")
// generate interface methods
for _, method := range service.Method {
methName := generator.CamelCase(method.GetName())
inType := g.typeName(method.GetInputType())
outType := g.typeName(method.GetOutputType())
if !method.GetServerStreaming() && !method.GetClientStreaming() {
g.P(methName, "(ctx ", contextPkg, ".Context, in *", inType, ", out *", outType, ") error")
continue
}
g.P(methName, "(ctx ", contextPkg, ".Context, stream server.Stream) error")
}
g.P("}")
g.P("type ", servName, " struct {")
g.P(unexport(servName))
g.P("}")
g.P("h := &", unexport(servName), "Handler{hdlr}")
for _, method := range service.Method {
if method.Options != nil && proto.HasExtension(method.Options, options.E_Http) {
g.P("opts = append(opts, ", apiPkg, ".WithEndpoint(&", apiPkg, ".Endpoint{")
g.generateEndpoint(servName, method)
g.P("}))")
}
}
g.P("return s.Handle(s.NewHandler(&", servName, "{h}, opts...))")
g.P("}")
g.P()
g.P("type ", unexport(servName), "Handler struct {")
g.P(serverType)
g.P("}")
// Server handler implementations.
var handlerNames []string
for _, method := range service.Method {
hname := g.generateServerMethod(servName, method)
handlerNames = append(handlerNames, hname)
}
}
// generateEndpoint creates the api endpoint
func (g *micro) generateEndpoint(servName string, method *pb.MethodDescriptorProto) {
if method.Options == nil || !proto.HasExtension(method.Options, options.E_Http) {
return
}
// http rules
r, err := proto.GetExtension(method.Options, options.E_Http)
if err != nil {
return
}
rule := r.(*options.HttpRule)
var meth string
var path string
switch {
case len(rule.GetDelete()) > 0:
meth = "DELETE"
path = rule.GetDelete()
case len(rule.GetGet()) > 0:
meth = "GET"
path = rule.GetGet()
case len(rule.GetPatch()) > 0:
meth = "PATCH"
path = rule.GetPatch()
case len(rule.GetPost()) > 0:
meth = "POST"
path = rule.GetPost()
case len(rule.GetPut()) > 0:
meth = "PUT"
path = rule.GetPut()
}
if len(meth) == 0 || len(path) == 0 {
return
}
// TODO: process additional bindings
g.P("Name:", fmt.Sprintf(`"%s.%s",`, servName, method.GetName()))
g.P("Path:", fmt.Sprintf(`[]string{"%s"},`, path))
g.P("Method:", fmt.Sprintf(`[]string{"%s"},`, meth))
if len(rule.GetGet()) == 0 {
g.P("Body:", fmt.Sprintf(`"%s",`, rule.GetBody()))
}
if method.GetServerStreaming() || method.GetClientStreaming() {
g.P("Stream: true,")
}
g.P(`Handler: "rpc",`)
}
// generateClientSignature returns the client-side signature for a method.
func (g *micro) generateClientSignature(servName string, method *pb.MethodDescriptorProto) string {
origMethName := method.GetName()
methName := generator.CamelCase(origMethName)
if reservedClientName[methName] {
methName += "_"
}
reqArg := ", in *" + g.typeName(method.GetInputType())
if method.GetClientStreaming() {
reqArg = ""
}
respName := "*" + g.typeName(method.GetOutputType())
if method.GetServerStreaming() || method.GetClientStreaming() {
respName = servName + "_" + generator.CamelCase(origMethName) + "Service"
}
return fmt.Sprintf("%s(ctx %s.Context%s, opts ...%s.CallOption) (%s, error)", methName, contextPkg, reqArg, clientPkg, respName)
}
func (g *micro) generateClientMethod(reqServ, servName, serviceDescVar string, method *pb.MethodDescriptorProto, descExpr string) {
reqMethod := fmt.Sprintf("%s.%s", servName, method.GetName())
methName := generator.CamelCase(method.GetName())
inType := g.typeName(method.GetInputType())
outType := g.typeName(method.GetOutputType())
servAlias := servName + "Service"
// strip suffix
if strings.HasSuffix(servAlias, "ServiceService") {
servAlias = strings.TrimSuffix(servAlias, "Service")
}
g.P("func (c *", unexport(servAlias), ") ", g.generateClientSignature(servName, method), "{")
if !method.GetServerStreaming() && !method.GetClientStreaming() {
g.P(`req := c.c.NewRequest(c.name, "`, reqMethod, `", in)`)
g.P("out := new(", outType, ")")
// TODO: Pass descExpr to Invoke.
g.P("err := ", `c.c.Call(ctx, req, out, opts...)`)
g.P("if err != nil { return nil, err }")
g.P("return out, nil")
g.P("}")
g.P()
return
}
streamType := unexport(servAlias) + methName
g.P(`req := c.c.NewRequest(c.name, "`, reqMethod, `", &`, inType, `{})`)
g.P("stream, err := c.c.Stream(ctx, req, opts...)")
g.P("if err != nil { return nil, err }")
if !method.GetClientStreaming() {
g.P("if err := stream.Send(in); err != nil { return nil, err }")
}
g.P("return &", streamType, "{stream}, nil")
g.P("}")
g.P()
genSend := method.GetClientStreaming()
genRecv := method.GetServerStreaming()
// Stream auxiliary types and methods.
g.P("type ", servName, "_", methName, "Service interface {")
g.P("Context() context.Context")
g.P("SendMsg(interface{}) error")
g.P("RecvMsg(interface{}) error")
g.P("Close() error")
if genSend {
g.P("Send(*", inType, ") error")
}
if genRecv {
g.P("Recv() (*", outType, ", error)")
}
g.P("}")
g.P()
g.P("type ", streamType, " struct {")
g.P("stream ", clientPkg, ".Stream")
g.P("}")
g.P()
g.P("func (x *", streamType, ") Close() error {")
g.P("return x.stream.Close()")
g.P("}")
g.P()
g.P("func (x *", streamType, ") Context() context.Context {")
g.P("return x.stream.Context()")
g.P("}")
g.P()
g.P("func (x *", streamType, ") SendMsg(m interface{}) error {")
g.P("return x.stream.Send(m)")
g.P("}")
g.P()
g.P("func (x *", streamType, ") RecvMsg(m interface{}) error {")
g.P("return x.stream.Recv(m)")
g.P("}")
g.P()
if genSend {
g.P("func (x *", streamType, ") Send(m *", inType, ") error {")
g.P("return x.stream.Send(m)")
g.P("}")
g.P()
}
if genRecv {
g.P("func (x *", streamType, ") Recv() (*", outType, ", error) {")
g.P("m := new(", outType, ")")
g.P("err := x.stream.Recv(m)")
g.P("if err != nil {")
g.P("return nil, err")
g.P("}")
g.P("return m, nil")
g.P("}")
g.P()
}
}
// generateServerSignature returns the server-side signature for a method.
func (g *micro) generateServerSignature(servName string, method *pb.MethodDescriptorProto) string {
origMethName := method.GetName()
methName := generator.CamelCase(origMethName)
if reservedClientName[methName] {
methName += "_"
}
var reqArgs []string
ret := "error"
reqArgs = append(reqArgs, contextPkg+".Context")
if !method.GetClientStreaming() {
reqArgs = append(reqArgs, "*"+g.typeName(method.GetInputType()))
}
if method.GetServerStreaming() || method.GetClientStreaming() {
reqArgs = append(reqArgs, servName+"_"+generator.CamelCase(origMethName)+"Stream")
}
if !method.GetClientStreaming() && !method.GetServerStreaming() {
reqArgs = append(reqArgs, "*"+g.typeName(method.GetOutputType()))
}
return methName + "(" + strings.Join(reqArgs, ", ") + ") " + ret
}
func (g *micro) generateServerMethod(servName string, method *pb.MethodDescriptorProto) string {
methName := generator.CamelCase(method.GetName())
hname := fmt.Sprintf("_%s_%s_Handler", servName, methName)
serveType := servName + "Handler"
inType := g.typeName(method.GetInputType())
outType := g.typeName(method.GetOutputType())
if !method.GetServerStreaming() && !method.GetClientStreaming() {
g.P("func (h *", unexport(servName), "Handler) ", methName, "(ctx ", contextPkg, ".Context, in *", inType, ", out *", outType, ") error {")
g.P("return h.", serveType, ".", methName, "(ctx, in, out)")
g.P("}")
g.P()
return hname
}
streamType := unexport(servName) + methName + "Stream"
g.P("func (h *", unexport(servName), "Handler) ", methName, "(ctx ", contextPkg, ".Context, stream server.Stream) error {")
if !method.GetClientStreaming() {
g.P("m := new(", inType, ")")
g.P("if err := stream.Recv(m); err != nil { return err }")
g.P("return h.", serveType, ".", methName, "(ctx, m, &", streamType, "{stream})")
} else {
g.P("return h.", serveType, ".", methName, "(ctx, &", streamType, "{stream})")
}
g.P("}")
g.P()
genSend := method.GetServerStreaming()
genRecv := method.GetClientStreaming()
// Stream auxiliary types and methods.
g.P("type ", servName, "_", methName, "Stream interface {")
g.P("Context() context.Context")
g.P("SendMsg(interface{}) error")
g.P("RecvMsg(interface{}) error")
g.P("Close() error")
if genSend {
g.P("Send(*", outType, ") error")
}
if genRecv {
g.P("Recv() (*", inType, ", error)")
}
g.P("}")
g.P()
g.P("type ", streamType, " struct {")
g.P("stream ", serverPkg, ".Stream")
g.P("}")
g.P()
g.P("func (x *", streamType, ") Close() error {")
g.P("return x.stream.Close()")
g.P("}")
g.P()
g.P("func (x *", streamType, ") Context() context.Context {")
g.P("return x.stream.Context()")
g.P("}")
g.P()
g.P("func (x *", streamType, ") SendMsg(m interface{}) error {")
g.P("return x.stream.Send(m)")
g.P("}")
g.P()
g.P("func (x *", streamType, ") RecvMsg(m interface{}) error {")
g.P("return x.stream.Recv(m)")
g.P("}")
g.P()
if genSend {
g.P("func (x *", streamType, ") Send(m *", outType, ") error {")
g.P("return x.stream.Send(m)")
g.P("}")
g.P()
}
if genRecv {
g.P("func (x *", streamType, ") Recv() (*", inType, ", error) {")
g.P("m := new(", inType, ")")
g.P("if err := x.stream.Recv(m); err != nil { return nil, err }")
g.P("return m, nil")
g.P("}")
g.P()
}
return hname
}

View File

@ -6,7 +6,7 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
) )
type Codec struct { type Codec struct {

View File

@ -1,7 +1,7 @@
package bytes package bytes
import ( import (
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
) )
type Marshaler struct{} type Marshaler struct{}

View File

@ -4,14 +4,14 @@ import (
"io" "io"
"testing" "testing"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
"github.com/micro/go-micro/v3/codec/bytes" "github.com/unistack-org/micro/v3/codec/bytes"
"github.com/micro/go-micro/v3/codec/grpc" "github.com/unistack-org/micro/v3/codec/grpc"
"github.com/micro/go-micro/v3/codec/json" "github.com/unistack-org/micro/v3/codec/json"
"github.com/micro/go-micro/v3/codec/jsonrpc" "github.com/unistack-org/micro/v3/codec/jsonrpc"
"github.com/micro/go-micro/v3/codec/proto" "github.com/unistack-org/micro/v3/codec/proto"
"github.com/micro/go-micro/v3/codec/protorpc" "github.com/unistack-org/micro/v3/codec/protorpc"
"github.com/micro/go-micro/v3/codec/text" "github.com/unistack-org/micro/v3/codec/text"
) )
type testRWC struct{} type testRWC struct{}

View File

@ -9,7 +9,7 @@ import (
"strings" "strings"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
) )
type Codec struct { type Codec struct {

View File

@ -7,7 +7,7 @@ import (
"github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
) )
type Codec struct { type Codec struct {

View File

@ -6,7 +6,7 @@ import (
"io" "io"
"sync" "sync"
"github.com/micro/go-micro/v3/codec" "github.com/unistack-org/micro/v3/codec"
) )
type clientCodec struct { type clientCodec struct {

Some files were not shown because too many files have changed in this diff Show More