micro-config-service/micro/service_micro_rpc.pb.go

66 lines
1.9 KiB
Go
Raw Normal View History

// Code generated by protoc-gen-micro
// source: service.proto
package service
import (
context "context"
proto "github.com/unistack-org/micro-config-service/v3/proto"
api "github.com/unistack-org/micro/v3/api"
client "github.com/unistack-org/micro/v3/client"
server "github.com/unistack-org/micro/v3/server"
)
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}
for _, endpoint := range NewConfigEndpoints() {
opts = append(opts, api.WithEndpoint(endpoint))
}
return s.Handle(s.NewHandler(&Config{h}, opts...))
}