micro/client/service/proto/client.pb.micro.go

208 lines
5.2 KiB
Go
Raw Normal View History

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