154 lines
4.0 KiB
Go
154 lines
4.0 KiB
Go
// Code generated by protoc-gen-micro
|
|
// source: registry.proto
|
|
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
micro_client "github.com/unistack-org/micro/v3/client"
|
|
micro_server "github.com/unistack-org/micro/v3/server"
|
|
)
|
|
|
|
var (
|
|
_ micro_server.Option
|
|
_ micro_client.Option
|
|
)
|
|
|
|
type registryService struct {
|
|
c micro_client.Client
|
|
name string
|
|
}
|
|
|
|
// Micro client stuff
|
|
|
|
// NewRegistryService create new service client
|
|
func NewRegistryService(name string, c micro_client.Client) RegistryService {
|
|
return ®istryService{c: c, name: name}
|
|
}
|
|
|
|
func (c *registryService) GetService(ctx context.Context, req *GetRequest, opts ...micro_client.CallOption) (*GetResponse, error) {
|
|
rsp := &GetResponse{}
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Registry.GetService", req), rsp, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return rsp, nil
|
|
}
|
|
|
|
func (c *registryService) Register(ctx context.Context, req *Service, opts ...micro_client.CallOption) (*EmptyResponse, error) {
|
|
rsp := &EmptyResponse{}
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Registry.Register", req), rsp, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return rsp, nil
|
|
}
|
|
|
|
func (c *registryService) Deregister(ctx context.Context, req *Service, opts ...micro_client.CallOption) (*EmptyResponse, error) {
|
|
rsp := &EmptyResponse{}
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Registry.Deregister", req), rsp, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return rsp, nil
|
|
}
|
|
|
|
func (c *registryService) ListServices(ctx context.Context, req *ListRequest, opts ...micro_client.CallOption) (*ListResponse, error) {
|
|
rsp := &ListResponse{}
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Registry.ListServices", req), rsp, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return rsp, nil
|
|
}
|
|
|
|
func (c *registryService) Watch(ctx context.Context, req *WatchRequest, opts ...micro_client.CallOption) (Registry_WatchService, error) {
|
|
stream, err := c.c.Stream(ctx, c.c.NewRequest(c.name, "Registry.Watch", &WatchRequest{}), opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if err := stream.Send(req); err != nil {
|
|
return nil, err
|
|
}
|
|
return ®istryServiceWatch{stream}, nil
|
|
}
|
|
|
|
type registryServiceWatch struct {
|
|
stream micro_client.Stream
|
|
}
|
|
|
|
func (x *registryServiceWatch) Close() error {
|
|
return x.stream.Close()
|
|
}
|
|
|
|
func (x *registryServiceWatch) Context() context.Context {
|
|
return x.stream.Context()
|
|
}
|
|
|
|
func (x *registryServiceWatch) SendMsg(m interface{}) error {
|
|
return x.stream.Send(m)
|
|
}
|
|
|
|
func (x *registryServiceWatch) RecvMsg(m interface{}) error {
|
|
return x.stream.Recv(m)
|
|
}
|
|
|
|
func (x *registryServiceWatch) Recv() (*Result, error) {
|
|
m := &Result{}
|
|
if err := x.stream.Recv(m); err != nil {
|
|
return nil, err
|
|
}
|
|
return m, nil
|
|
} // Micro server stuff
|
|
|
|
type registryHandler struct {
|
|
RegistryHandler
|
|
}
|
|
|
|
func (h *registryHandler) GetService(ctx context.Context, req *GetRequest, rsp *GetResponse) error {
|
|
return h.RegistryHandler.GetService(ctx, req, rsp)
|
|
}
|
|
|
|
func (h *registryHandler) Register(ctx context.Context, req *Service, rsp *EmptyResponse) error {
|
|
return h.RegistryHandler.Register(ctx, req, rsp)
|
|
}
|
|
|
|
func (h *registryHandler) Deregister(ctx context.Context, req *Service, rsp *EmptyResponse) error {
|
|
return h.RegistryHandler.Deregister(ctx, req, rsp)
|
|
}
|
|
|
|
func (h *registryHandler) ListServices(ctx context.Context, req *ListRequest, rsp *ListResponse) error {
|
|
return h.RegistryHandler.ListServices(ctx, req, rsp)
|
|
}
|
|
|
|
func (h *registryHandler) Watch(ctx context.Context, stream micro_server.Stream) error {
|
|
m := &WatchRequest{}
|
|
if err := stream.Recv(m); err != nil {
|
|
return err
|
|
}
|
|
return h.RegistryHandler.Watch(ctx, m, ®istryWatchStream{stream})
|
|
}
|
|
|
|
type registryWatchStream struct {
|
|
stream micro_server.Stream
|
|
}
|
|
|
|
func (x *registryWatchStream) Close() error {
|
|
return x.stream.Close()
|
|
}
|
|
|
|
func (x *registryWatchStream) Context() context.Context {
|
|
return x.stream.Context()
|
|
}
|
|
|
|
func (x *registryWatchStream) SendMsg(m interface{}) error {
|
|
return x.stream.Send(m)
|
|
}
|
|
|
|
func (x *registryWatchStream) RecvMsg(m interface{}) error {
|
|
return x.stream.Recv(m)
|
|
}
|
|
func (x *registryWatchStream) Send(m *Result) error {
|
|
return x.stream.Send(m)
|
|
}
|