fixup multiple clients support
Some checks failed
coverage / build (push) Failing after 0s
test / test (push) Failing after 1s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2026-02-24 11:38:27 +03:00
parent 1e3e2b5b3a
commit a9ba250245
10 changed files with 326 additions and 227 deletions

View File

@@ -0,0 +1,105 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// protoc-gen-go-micro version: v3.10.4
// source: service.proto
package servicepb
import (
context "context"
v41 "go.unistack.org/micro-client-http/v4"
proto "go.unistack.org/micro-config-service/v4/proto"
v4 "go.unistack.org/micro-server-http/v4"
client "go.unistack.org/micro/v4/client"
server "go.unistack.org/micro/v4/server"
http "net/http"
)
var (
ConfigServerEndpoints = []v4.EndpointMetadata{
{
Name: "Config.Load",
Path: "/load",
Method: "GET",
Body: "",
Stream: false,
},
{
Name: "Config.Save",
Path: "/save",
Method: "POST",
Body: "*",
Stream: false,
},
}
)
type configClient struct {
c client.Client
name string
}
func NewConfigClient(name string, c client.Client) proto.ConfigClient {
return &configClient{c: c, name: name}
}
func (c *configClient) Load(ctx context.Context, req *proto.LoadRequest, opts ...client.CallOption) (*proto.LoadResponse, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &proto.Error{}
opts = append(opts,
v41.ErrorMap(errmap),
)
opts = append(opts,
v41.Method(http.MethodGet),
v41.Path("/load"),
)
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) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &proto.Error{}
opts = append(opts,
v41.ErrorMap(errmap),
)
opts = append(opts,
v41.Method(http.MethodPost),
v41.Path("/save"),
v41.Body("*"),
)
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 {
proto.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 proto.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}
opts = append(opts, v4.HandlerEndpoints(ConfigServerEndpoints))
return s.Handle(s.NewHandler(&Config{h}, opts...))
}