2019-06-18 18:51:52 +01:00
|
|
|
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
2020-03-30 23:58:32 +03:00
|
|
|
// source: client/service/proto/client.proto
|
2019-06-18 18:51:52 +01:00
|
|
|
|
|
|
|
package go_micro_client
|
|
|
|
|
|
|
|
import (
|
|
|
|
fmt "fmt"
|
|
|
|
proto "github.com/golang/protobuf/proto"
|
|
|
|
math "math"
|
|
|
|
)
|
|
|
|
|
|
|
|
import (
|
|
|
|
context "context"
|
2020-04-14 16:25:09 +03:00
|
|
|
api "github.com/micro/go-micro/v2/api"
|
2020-01-30 14:39:00 +03:00
|
|
|
client "github.com/micro/go-micro/v2/client"
|
|
|
|
server "github.com/micro/go-micro/v2/server"
|
2019-06-18 18:51:52 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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.
|
2020-04-14 16:25:09 +03:00
|
|
|
var _ api.Endpoint
|
2019-06-18 18:51:52 +01:00
|
|
|
var _ context.Context
|
|
|
|
var _ client.Option
|
|
|
|
var _ server.Option
|
|
|
|
|
2020-04-14 16:25:09 +03:00
|
|
|
// Api Endpoints for Client service
|
|
|
|
|
|
|
|
func NewClientEndpoints() []*api.Endpoint {
|
|
|
|
return []*api.Endpoint{}
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
// Client API for Client service
|
2019-06-18 18:51:52 +01:00
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
type ClientService interface {
|
2019-06-18 18:51:52 +01:00
|
|
|
// Call allows a single request to be made
|
|
|
|
Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error)
|
|
|
|
// Stream is a bidirectional stream
|
2019-08-23 12:06:11 +01:00
|
|
|
Stream(ctx context.Context, opts ...client.CallOption) (Client_StreamService, error)
|
2019-06-18 18:51:52 +01:00
|
|
|
// Publish publishes a message and returns an empty Message
|
|
|
|
Publish(ctx context.Context, in *Message, opts ...client.CallOption) (*Message, error)
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
type clientService struct {
|
2019-06-18 18:51:52 +01:00
|
|
|
c client.Client
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func NewClientService(name string, c client.Client) ClientService {
|
|
|
|
return &clientService{
|
2019-06-18 18:51:52 +01:00
|
|
|
c: c,
|
|
|
|
name: name,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (c *clientService) Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) {
|
|
|
|
req := c.c.NewRequest(c.name, "Client.Call", in)
|
2019-06-18 18:51:52 +01:00
|
|
|
out := new(Response)
|
|
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (c *clientService) Stream(ctx context.Context, opts ...client.CallOption) (Client_StreamService, error) {
|
|
|
|
req := c.c.NewRequest(c.name, "Client.Stream", &Request{})
|
2019-06-18 18:51:52 +01:00
|
|
|
stream, err := c.c.Stream(ctx, req, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-08-23 12:06:11 +01:00
|
|
|
return &clientServiceStream{stream}, nil
|
2019-06-18 18:51:52 +01:00
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
type Client_StreamService interface {
|
2020-03-30 23:58:32 +03:00
|
|
|
Context() context.Context
|
2019-06-18 18:51:52 +01:00
|
|
|
SendMsg(interface{}) error
|
|
|
|
RecvMsg(interface{}) error
|
|
|
|
Close() error
|
|
|
|
Send(*Request) error
|
|
|
|
Recv() (*Response, error)
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
type clientServiceStream struct {
|
2019-06-18 18:51:52 +01:00
|
|
|
stream client.Stream
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (x *clientServiceStream) Close() error {
|
2019-06-18 18:51:52 +01:00
|
|
|
return x.stream.Close()
|
|
|
|
}
|
|
|
|
|
2020-03-30 23:58:32 +03:00
|
|
|
func (x *clientServiceStream) Context() context.Context {
|
|
|
|
return x.stream.Context()
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (x *clientServiceStream) SendMsg(m interface{}) error {
|
2019-06-18 18:51:52 +01:00
|
|
|
return x.stream.Send(m)
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (x *clientServiceStream) RecvMsg(m interface{}) error {
|
2019-06-18 18:51:52 +01:00
|
|
|
return x.stream.Recv(m)
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (x *clientServiceStream) Send(m *Request) error {
|
2019-06-18 18:51:52 +01:00
|
|
|
return x.stream.Send(m)
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (x *clientServiceStream) Recv() (*Response, error) {
|
2019-06-18 18:51:52 +01:00
|
|
|
m := new(Response)
|
|
|
|
err := x.stream.Recv(m)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return m, nil
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (c *clientService) Publish(ctx context.Context, in *Message, opts ...client.CallOption) (*Message, error) {
|
|
|
|
req := c.c.NewRequest(c.name, "Client.Publish", in)
|
2019-06-18 18:51:52 +01:00
|
|
|
out := new(Message)
|
|
|
|
err := c.c.Call(ctx, req, out, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
// Server API for Client service
|
2019-06-18 18:51:52 +01:00
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
type ClientHandler interface {
|
2019-06-18 18:51:52 +01:00
|
|
|
// Call allows a single request to be made
|
|
|
|
Call(context.Context, *Request, *Response) error
|
|
|
|
// Stream is a bidirectional stream
|
2019-08-23 12:06:11 +01:00
|
|
|
Stream(context.Context, Client_StreamStream) error
|
2019-06-18 18:51:52 +01:00
|
|
|
// Publish publishes a message and returns an empty Message
|
|
|
|
Publish(context.Context, *Message, *Message) error
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func RegisterClientHandler(s server.Server, hdlr ClientHandler, opts ...server.HandlerOption) error {
|
|
|
|
type client interface {
|
2019-06-18 18:51:52 +01:00
|
|
|
Call(ctx context.Context, in *Request, out *Response) error
|
|
|
|
Stream(ctx context.Context, stream server.Stream) error
|
|
|
|
Publish(ctx context.Context, in *Message, out *Message) error
|
|
|
|
}
|
2019-08-23 12:06:11 +01:00
|
|
|
type Client struct {
|
|
|
|
client
|
2019-06-18 18:51:52 +01:00
|
|
|
}
|
2019-08-23 12:06:11 +01:00
|
|
|
h := &clientHandler{hdlr}
|
|
|
|
return s.Handle(s.NewHandler(&Client{h}, opts...))
|
2019-06-18 18:51:52 +01:00
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
type clientHandler struct {
|
|
|
|
ClientHandler
|
2019-06-18 18:51:52 +01:00
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (h *clientHandler) Call(ctx context.Context, in *Request, out *Response) error {
|
|
|
|
return h.ClientHandler.Call(ctx, in, out)
|
2019-06-18 18:51:52 +01:00
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (h *clientHandler) Stream(ctx context.Context, stream server.Stream) error {
|
|
|
|
return h.ClientHandler.Stream(ctx, &clientStreamStream{stream})
|
2019-06-18 18:51:52 +01:00
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
type Client_StreamStream interface {
|
2020-03-30 23:58:32 +03:00
|
|
|
Context() context.Context
|
2019-06-18 18:51:52 +01:00
|
|
|
SendMsg(interface{}) error
|
|
|
|
RecvMsg(interface{}) error
|
|
|
|
Close() error
|
|
|
|
Send(*Response) error
|
|
|
|
Recv() (*Request, error)
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
type clientStreamStream struct {
|
2019-06-18 18:51:52 +01:00
|
|
|
stream server.Stream
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (x *clientStreamStream) Close() error {
|
2019-06-18 18:51:52 +01:00
|
|
|
return x.stream.Close()
|
|
|
|
}
|
|
|
|
|
2020-03-30 23:58:32 +03:00
|
|
|
func (x *clientStreamStream) Context() context.Context {
|
|
|
|
return x.stream.Context()
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (x *clientStreamStream) SendMsg(m interface{}) error {
|
2019-06-18 18:51:52 +01:00
|
|
|
return x.stream.Send(m)
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (x *clientStreamStream) RecvMsg(m interface{}) error {
|
2019-06-18 18:51:52 +01:00
|
|
|
return x.stream.Recv(m)
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (x *clientStreamStream) Send(m *Response) error {
|
2019-06-18 18:51:52 +01:00
|
|
|
return x.stream.Send(m)
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (x *clientStreamStream) Recv() (*Request, error) {
|
2019-06-18 18:51:52 +01:00
|
|
|
m := new(Request)
|
|
|
|
if err := x.stream.Recv(m); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return m, nil
|
|
|
|
}
|
|
|
|
|
2019-08-23 12:06:11 +01:00
|
|
|
func (h *clientHandler) Publish(ctx context.Context, in *Message, out *Message) error {
|
|
|
|
return h.ClientHandler.Publish(ctx, in, out)
|
2019-06-18 18:51:52 +01:00
|
|
|
}
|