Created
April 16, 2019 14:31
-
-
Save swedishborgie/31ec530a9ca9394466929251f1c68ce6 to your computer and use it in GitHub Desktop.
protoc-gen-micro issue 42 clarification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
protoc -I. --micro_out=. my.srv.opps/proto/opps.proto | |
protoc -I. --micro_out=. my.another.srv.opps/proto/opps.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code generated by protoc-gen-micro. DO NOT EDIT. | |
// source: my.another.srv.opps/proto/opps.proto | |
package my_another_srv_opps | |
import ( | |
fmt "fmt" | |
proto "github.com/golang/protobuf/proto" | |
math "math" | |
proto1 "my.srv.opps/proto" | |
) | |
import ( | |
context "context" | |
client "github.com/micro/go-micro/client" | |
server "github.com/micro/go-micro/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 _ context.Context | |
var _ client.Option | |
var _ server.Option | |
// Client API for Opps service | |
type OppsService interface { | |
UseOpps(ctx context.Context, in *Request, opts ...client.CallOption) (*proto1.MyMessage, error) | |
} | |
type oppsService struct { | |
c client.Client | |
name string | |
} | |
func NewOppsService(name string, c client.Client) OppsService { | |
if c == nil { | |
c = client.NewClient() | |
} | |
if len(name) == 0 { | |
name = "my.another.srv.opps" | |
} | |
return &oppsService{ | |
c: c, | |
name: name, | |
} | |
} | |
func (c *oppsService) UseOpps(ctx context.Context, in *Request, opts ...client.CallOption) (*proto1.MyMessage, error) { | |
req := c.c.NewRequest(c.name, "Opps.UseOpps", in) | |
out := new(proto1.MyMessage) | |
err := c.c.Call(ctx, req, out, opts...) | |
if err != nil { | |
return nil, err | |
} | |
return out, nil | |
} | |
// Server API for Opps service | |
type OppsHandler interface { | |
UseOpps(context.Context, *Request, *proto1.MyMessage) error | |
} | |
func RegisterOppsHandler(s server.Server, hdlr OppsHandler, opts ...server.HandlerOption) error { | |
type opps interface { | |
UseOpps(ctx context.Context, in *Request, out *proto1.MyMessage) error | |
} | |
type Opps struct { | |
opps | |
} | |
h := &oppsHandler{hdlr} | |
return s.Handle(s.NewHandler(&Opps{h}, opts...)) | |
} | |
type oppsHandler struct { | |
OppsHandler | |
} | |
func (h *oppsHandler) UseOpps(ctx context.Context, in *Request, out *proto1.MyMessage) error { | |
return h.OppsHandler.UseOpps(ctx, in, out) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto3"; | |
package my.another.srv.opps; | |
import "my.srv.opps/proto/opps.proto"; | |
service Opps { // notice that I am using the same service name in different `package` | |
rpc UseOpps(Request) returns (my.srv.opps.MyMessage); // used to generate my_srv_opps.MyMessage | |
} | |
message Request { | |
string query = 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code generated by protoc-gen-micro. DO NOT EDIT. | |
// source: my.srv.opps/proto/opps.proto | |
package opps | |
import ( | |
fmt "fmt" | |
proto "github.com/golang/protobuf/proto" | |
math "math" | |
) | |
import ( | |
context "context" | |
client "github.com/micro/go-micro/client" | |
server "github.com/micro/go-micro/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 _ context.Context | |
var _ client.Option | |
var _ server.Option | |
// Client API for Opps service | |
type OppsService interface { | |
} | |
type oppsService struct { | |
c client.Client | |
name string | |
} | |
func NewOppsService(name string, c client.Client) OppsService { | |
if c == nil { | |
c = client.NewClient() | |
} | |
if len(name) == 0 { | |
name = "my.srv.opps" | |
} | |
return &oppsService{ | |
c: c, | |
name: name, | |
} | |
} | |
// Server API for Opps service | |
type OppsHandler interface { | |
} | |
func RegisterOppsHandler(s server.Server, hdlr OppsHandler, opts ...server.HandlerOption) error { | |
type opps interface { | |
} | |
type Opps struct { | |
opps | |
} | |
h := &oppsHandler{hdlr} | |
return s.Handle(s.NewHandler(&Opps{h}, opts...)) | |
} | |
type oppsHandler struct { | |
OppsHandler | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto3"; | |
package my.srv.opps; // used to honour this and name the variable as `my_srv_opps` | |
option go_package = "opps"; | |
service Opps { | |
} | |
message MyMessage { | |
string test = 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment