2021-10-26 23:32:16 +03:00
|
|
|
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
|
|
|
// protoc-gen-go-micro version: v3.5.3
|
2021-03-22 08:59:52 +03:00
|
|
|
// source: service.proto
|
2021-10-26 23:32:16 +03:00
|
|
|
|
2021-05-09 18:47:50 +03:00
|
|
|
package servicepb
|
2021-03-22 08:59:52 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
context "context"
|
2021-10-26 23:32:16 +03:00
|
|
|
proto "go.unistack.org/micro-config-service/v3/proto"
|
|
|
|
api "go.unistack.org/micro/v3/api"
|
|
|
|
client "go.unistack.org/micro/v3/client"
|
|
|
|
server "go.unistack.org/micro/v3/server"
|
2021-03-22 08:59:52 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type configClient struct {
|
|
|
|
c client.Client
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewConfigClient(name string, c client.Client) ConfigClient {
|
|
|
|
return &configClient{c: c, name: name}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configClient) Load(ctx context.Context, req *proto.LoadRequest, opts ...client.CallOption) (*proto.LoadResponse, error) {
|
|
|
|
rsp := &proto.LoadResponse{}
|
|
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Config.Load", req), rsp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return rsp, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configClient) Save(ctx context.Context, req *proto.SaveRequest, opts ...client.CallOption) (*proto.SaveResponse, error) {
|
|
|
|
rsp := &proto.SaveResponse{}
|
|
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Config.Save", req), rsp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return rsp, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type configServer struct {
|
|
|
|
ConfigServer
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *configServer) Load(ctx context.Context, req *proto.LoadRequest, rsp *proto.LoadResponse) error {
|
|
|
|
return h.ConfigServer.Load(ctx, req, rsp)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *configServer) Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.SaveResponse) error {
|
|
|
|
return h.ConfigServer.Save(ctx, req, rsp)
|
|
|
|
}
|
|
|
|
|
|
|
|
func RegisterConfigServer(s server.Server, sh ConfigServer, opts ...server.HandlerOption) error {
|
|
|
|
type config interface {
|
|
|
|
Load(ctx context.Context, req *proto.LoadRequest, rsp *proto.LoadResponse) error
|
|
|
|
Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.SaveResponse) error
|
|
|
|
}
|
|
|
|
type Config struct {
|
|
|
|
config
|
|
|
|
}
|
|
|
|
h := &configServer{sh}
|
2021-05-09 18:47:50 +03:00
|
|
|
var nopts []server.HandlerOption
|
2021-10-26 23:32:16 +03:00
|
|
|
for _, endpoint := range ConfigEndpoints {
|
|
|
|
nopts = append(nopts, api.WithEndpoint(&endpoint))
|
2021-03-22 08:59:52 +03:00
|
|
|
}
|
2021-05-09 18:47:50 +03:00
|
|
|
return s.Handle(s.NewHandler(&Config{h}, append(nopts, opts...)...))
|
2021-03-22 08:59:52 +03:00
|
|
|
}
|