fixup multiple clients support
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
//go:generate protoc -I./proto -I. --go-grpc_out=paths=source_relative:./proto --go_out=paths=source_relative:./proto --go-micro_out=components=micro|grpc,standalone=true,debug=true,paths=source_relative:./micro proto/service.proto
|
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v4) --go_out=paths=source_relative:./proto proto/service.proto"
|
||||||
|
|
||||||
|
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v4) --go-micro_out=components=micro,debug=true,paths=source_relative:./proto proto/service.proto"
|
||||||
|
|
||||||
|
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v4) --go-micro_out=components=grpc,standalone=true,debug=true,paths=source_relative:./grpc proto/service.proto"
|
||||||
|
|
||||||
|
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v4) --go-micro_out=components=http,standalone=true,debug=true,paths=source_relative:./http proto/service.proto"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||||
// protoc-gen-go-micro version: v4.1.0
|
// protoc-gen-go-micro version: v3.10.4
|
||||||
// source: service.proto
|
// source: service.proto
|
||||||
|
|
||||||
package servicepb
|
package servicepb
|
||||||
@@ -16,7 +16,7 @@ type configClient struct {
|
|||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfigClient(name string, c client.Client) ConfigClient {
|
func NewConfigClient(name string, c client.Client) proto.ConfigClient {
|
||||||
return &configClient{c: c, name: name}
|
return &configClient{c: c, name: name}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ func (c *configClient) Save(ctx context.Context, req *proto.SaveRequest, opts ..
|
|||||||
}
|
}
|
||||||
|
|
||||||
type configServer struct {
|
type configServer struct {
|
||||||
ConfigServer
|
proto.ConfigServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *configServer) Load(ctx context.Context, req *proto.LoadRequest, rsp *proto.LoadResponse) error {
|
func (h *configServer) Load(ctx context.Context, req *proto.LoadRequest, rsp *proto.LoadResponse) error {
|
||||||
@@ -50,7 +50,7 @@ func (h *configServer) Save(ctx context.Context, req *proto.SaveRequest, rsp *pr
|
|||||||
return h.ConfigServer.Save(ctx, req, rsp)
|
return h.ConfigServer.Save(ctx, req, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterConfigServer(s server.Server, sh ConfigServer, opts ...server.HandlerOption) error {
|
func RegisterConfigServer(s server.Server, sh proto.ConfigServer, opts ...server.HandlerOption) error {
|
||||||
type config interface {
|
type config interface {
|
||||||
Load(ctx context.Context, req *proto.LoadRequest, rsp *proto.LoadResponse) error
|
Load(ctx context.Context, req *proto.LoadRequest, rsp *proto.LoadResponse) error
|
||||||
Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.SaveResponse) error
|
Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.SaveResponse) error
|
||||||
105
http/service_micro_http.pb.go
Normal file
105
http/service_micro_http.pb.go
Normal 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...))
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// - protoc-gen-go-micro v4.1.0
|
|
||||||
// - protoc v5.29.3
|
|
||||||
// source: service.proto
|
|
||||||
|
|
||||||
package servicepb
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
proto "go.unistack.org/micro-config-service/v4/proto"
|
|
||||||
client "go.unistack.org/micro/v4/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
ConfigName = "Config"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ConfigClient interface {
|
|
||||||
Load(ctx context.Context, req *proto.LoadRequest, opts ...client.CallOption) (*proto.LoadResponse, error)
|
|
||||||
Save(ctx context.Context, req *proto.SaveRequest, opts ...client.CallOption) (*proto.SaveResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConfigServer interface {
|
|
||||||
Load(ctx context.Context, req *proto.LoadRequest, rsp *proto.LoadResponse) error
|
|
||||||
Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.SaveResponse) error
|
|
||||||
}
|
|
||||||
17
proto/micro_errors.pb.go
Normal file
17
proto/micro_errors.pb.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||||
|
// protoc-gen-go-micro version: v3.10.4
|
||||||
|
|
||||||
|
package servicepb
|
||||||
|
|
||||||
|
import (
|
||||||
|
protojson "google.golang.org/protobuf/encoding/protojson"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
marshaler = protojson.MarshalOptions{}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (m *Error) Error() string {
|
||||||
|
buf, _ := marshaler.Marshal(m)
|
||||||
|
return string(buf)
|
||||||
|
}
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.26.0
|
// protoc-gen-go v1.26.0
|
||||||
// protoc v5.29.3
|
// protoc v6.33.4
|
||||||
// source: service.proto
|
// source: service.proto
|
||||||
|
|
||||||
package servicepb
|
package servicepb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "go.unistack.org/micro-proto/v4/api"
|
||||||
|
_ "go.unistack.org/micro-proto/v4/openapiv3"
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
@@ -20,11 +22,13 @@ const (
|
|||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// LoadRequest — запрос на загрузку конфигурации
|
||||||
type LoadRequest struct {
|
type LoadRequest struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// service — имя сервиса для которого загружается конфигурация
|
||||||
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
|
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,11 +71,13 @@ func (x *LoadRequest) GetService() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadResponse — ответ на запрос конфигурации
|
||||||
type LoadResponse struct {
|
type LoadResponse struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// config — данные конфигурации в формате JSON/YAML
|
||||||
Config []byte `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"`
|
Config []byte `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,12 +120,15 @@ func (x *LoadResponse) GetConfig() []byte {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SaveRequest — запрос на сохранение конфигурации
|
||||||
type SaveRequest struct {
|
type SaveRequest struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// service — имя сервиса для которого сохраняется конфигурация
|
||||||
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
|
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
|
||||||
|
// config — данные конфигурации в формате JSON/YAML
|
||||||
Config []byte `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"`
|
Config []byte `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,6 +178,8 @@ func (x *SaveRequest) GetConfig() []byte {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SaveResponse — ответ на запрос сохранения конфигурации
|
||||||
|
// Пустое сообщение, успешное сохранение подтверждается отсутствием ошибки
|
||||||
type SaveResponse struct {
|
type SaveResponse struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
@@ -207,33 +218,83 @@ func (*SaveResponse) Descriptor() ([]byte, []int) {
|
|||||||
return file_service_proto_rawDescGZIP(), []int{3}
|
return file_service_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error — сообщение об ошибке
|
||||||
|
// Возвращается при возникновении ошибок в методах сервиса Config
|
||||||
|
type Error struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Error) Reset() {
|
||||||
|
*x = Error{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_service_proto_msgTypes[4]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Error) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Error) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *Error) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_service_proto_msgTypes[4]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use Error.ProtoReflect.Descriptor instead.
|
||||||
|
func (*Error) Descriptor() ([]byte, []int) {
|
||||||
|
return file_service_proto_rawDescGZIP(), []int{4}
|
||||||
|
}
|
||||||
|
|
||||||
var File_service_proto protoreflect.FileDescriptor
|
var File_service_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_service_proto_rawDesc = []byte{
|
var file_service_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||||
0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x27, 0x0a, 0x0b, 0x4c, 0x6f, 0x61, 0x64,
|
0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a, 0x15, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e,
|
||||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69,
|
0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a,
|
||||||
0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
|
0x1b, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74,
|
||||||
0x65, 0x22, 0x26, 0x0a, 0x0c, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x27, 0x0a, 0x0b,
|
||||||
0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73,
|
||||||
0x0c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x3f, 0x0a, 0x0b, 0x53, 0x61, 0x76,
|
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65,
|
||||||
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76,
|
0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x26, 0x0a, 0x0c, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73,
|
||||||
0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69,
|
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18,
|
||||||
0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01,
|
0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x3f, 0x0a,
|
||||||
0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x0e, 0x0a, 0x0c, 0x53, 0x61,
|
0x0b, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07,
|
||||||
0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x76, 0x0a, 0x06, 0x43, 0x6f,
|
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73,
|
||||||
0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, 0x0a, 0x04, 0x4c, 0x6f, 0x61, 0x64, 0x12, 0x14, 0x2e, 0x73,
|
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
|
||||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65,
|
0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x0e,
|
||||||
0x73, 0x74, 0x1a, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x6f, 0x61,
|
0x0a, 0x0c, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x07,
|
||||||
0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x04, 0x53,
|
0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x32, 0xd5, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66,
|
||||||
0x61, 0x76, 0x65, 0x12, 0x14, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x61,
|
0x69, 0x67, 0x12, 0x63, 0x0a, 0x04, 0x4c, 0x6f, 0x61, 0x64, 0x12, 0x14, 0x2e, 0x73, 0x65, 0x72,
|
||||||
0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x76,
|
0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||||
0x69, 0x63, 0x65, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
0x1a, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x52,
|
||||||
0x22, 0x00, 0x42, 0x39, 0x5a, 0x37, 0x67, 0x6f, 0x2e, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63,
|
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e, 0xaa, 0x84, 0x9e, 0x03, 0x1c, 0x2a, 0x04,
|
||||||
0x6b, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x66,
|
0x4c, 0x6f, 0x61, 0x64, 0x42, 0x14, 0x0a, 0x12, 0x12, 0x10, 0x0a, 0x0e, 0x2e, 0x73, 0x65, 0x72,
|
||||||
0x69, 0x67, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x34, 0x2f, 0x70, 0x72,
|
0x76, 0x69, 0x63, 0x65, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x07,
|
||||||
0x6f, 0x74, 0x6f, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70,
|
0x12, 0x05, 0x2f, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x66, 0x0a, 0x04, 0x53, 0x61, 0x76, 0x65, 0x12,
|
||||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x14, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65,
|
||||||
|
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e,
|
||||||
|
0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x31, 0xaa, 0x84,
|
||||||
|
0x9e, 0x03, 0x1c, 0x2a, 0x04, 0x53, 0x61, 0x76, 0x65, 0x42, 0x14, 0x0a, 0x12, 0x12, 0x10, 0x0a,
|
||||||
|
0x0e, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0xb2,
|
||||||
|
0xea, 0xff, 0xf9, 0x01, 0x0a, 0x22, 0x05, 0x2f, 0x73, 0x61, 0x76, 0x65, 0x3a, 0x01, 0x2a, 0x42,
|
||||||
|
0x39, 0x5a, 0x37, 0x67, 0x6f, 0x2e, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x6f,
|
||||||
|
0x72, 0x67, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2d,
|
||||||
|
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x34, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
|
0x3b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||||
|
0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -248,12 +309,13 @@ func file_service_proto_rawDescGZIP() []byte {
|
|||||||
return file_service_proto_rawDescData
|
return file_service_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||||
var file_service_proto_goTypes = []interface{}{
|
var file_service_proto_goTypes = []interface{}{
|
||||||
(*LoadRequest)(nil), // 0: service.LoadRequest
|
(*LoadRequest)(nil), // 0: service.LoadRequest
|
||||||
(*LoadResponse)(nil), // 1: service.LoadResponse
|
(*LoadResponse)(nil), // 1: service.LoadResponse
|
||||||
(*SaveRequest)(nil), // 2: service.SaveRequest
|
(*SaveRequest)(nil), // 2: service.SaveRequest
|
||||||
(*SaveResponse)(nil), // 3: service.SaveResponse
|
(*SaveResponse)(nil), // 3: service.SaveResponse
|
||||||
|
(*Error)(nil), // 4: service.Error
|
||||||
}
|
}
|
||||||
var file_service_proto_depIdxs = []int32{
|
var file_service_proto_depIdxs = []int32{
|
||||||
0, // 0: service.Config.Load:input_type -> service.LoadRequest
|
0, // 0: service.Config.Load:input_type -> service.LoadRequest
|
||||||
@@ -321,6 +383,18 @@ func file_service_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*Error); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
type x struct{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
@@ -328,7 +402,7 @@ func file_service_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_service_proto_rawDesc,
|
RawDescriptor: file_service_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 4,
|
NumMessages: 5,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,22 +3,71 @@ syntax = "proto3";
|
|||||||
package service;
|
package service;
|
||||||
option go_package="go.unistack.org/micro-config-service/v4/proto;servicepb";
|
option go_package="go.unistack.org/micro-config-service/v4/proto;servicepb";
|
||||||
|
|
||||||
|
import "api/annotations.proto";
|
||||||
|
import "openapiv3/annotations.proto";
|
||||||
|
|
||||||
|
// Config — сервис управления конфигурациями
|
||||||
|
// Предоставляет API для загрузки и сохранения конфигураций сервисов
|
||||||
service Config {
|
service Config {
|
||||||
rpc Load(LoadRequest) returns (LoadResponse) {};
|
// Load загружает конфигурацию для указанного сервиса
|
||||||
rpc Save(SaveRequest) returns (SaveResponse) {};
|
// Возвращает конфигурацию в формате JSON/YAML в поле config
|
||||||
|
rpc Load(LoadRequest) returns (LoadResponse) {
|
||||||
|
option (micro.openapiv3.openapiv3_operation) = {
|
||||||
|
operation_id: "Load";
|
||||||
|
responses: {
|
||||||
|
default: {
|
||||||
|
reference: {
|
||||||
|
_ref: ".service.Error";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
option (micro.api.http) = { get: "/load"; };
|
||||||
|
};
|
||||||
|
|
||||||
|
// Save сохраняет конфигурацию для указанного сервиса
|
||||||
|
// Принимает конфигурацию в формате JSON/YAML в поле config
|
||||||
|
rpc Save(SaveRequest) returns (SaveResponse) {
|
||||||
|
option (micro.openapiv3.openapiv3_operation) = {
|
||||||
|
operation_id: "Save";
|
||||||
|
responses: {
|
||||||
|
default: {
|
||||||
|
reference: {
|
||||||
|
_ref: ".service.Error";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
option (micro.api.http) = { post: "/save"; body: "*"; };
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadRequest — запрос на загрузку конфигурации
|
||||||
message LoadRequest {
|
message LoadRequest {
|
||||||
|
// service — имя сервиса для которого загружается конфигурация
|
||||||
string service = 1;
|
string service = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// LoadResponse — ответ на запрос конфигурации
|
||||||
message LoadResponse {
|
message LoadResponse {
|
||||||
|
// config — данные конфигурации в формате JSON/YAML
|
||||||
bytes config = 1;
|
bytes config = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// SaveRequest — запрос на сохранение конфигурации
|
||||||
message SaveRequest {
|
message SaveRequest {
|
||||||
|
// service — имя сервиса для которого сохраняется конфигурация
|
||||||
string service = 1;
|
string service = 1;
|
||||||
|
// config — данные конфигурации в формате JSON/YAML
|
||||||
bytes config = 2;
|
bytes config = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// SaveResponse — ответ на запрос сохранения конфигурации
|
||||||
|
// Пустое сообщение, успешное сохранение подтверждается отсутствием ошибки
|
||||||
message SaveResponse {};
|
message SaveResponse {};
|
||||||
|
|
||||||
|
// Error — сообщение об ошибке
|
||||||
|
// Возвращается при возникновении ошибок в методах сервиса Config
|
||||||
|
message Error {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// - protoc-gen-go-grpc v1.5.1
|
|
||||||
// - protoc v5.29.3
|
|
||||||
// source: service.proto
|
|
||||||
|
|
||||||
package servicepb
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
grpc "google.golang.org/grpc"
|
|
||||||
codes "google.golang.org/grpc/codes"
|
|
||||||
status "google.golang.org/grpc/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the grpc package it is being compiled against.
|
|
||||||
// Requires gRPC-Go v1.64.0 or later.
|
|
||||||
const _ = grpc.SupportPackageIsVersion9
|
|
||||||
|
|
||||||
const (
|
|
||||||
Config_Load_FullMethodName = "/service.Config/Load"
|
|
||||||
Config_Save_FullMethodName = "/service.Config/Save"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ConfigClient is the client API for Config service.
|
|
||||||
//
|
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
||||||
type ConfigClient interface {
|
|
||||||
Load(ctx context.Context, in *LoadRequest, opts ...grpc.CallOption) (*LoadResponse, error)
|
|
||||||
Save(ctx context.Context, in *SaveRequest, opts ...grpc.CallOption) (*SaveResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type configClient struct {
|
|
||||||
cc grpc.ClientConnInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewConfigClient(cc grpc.ClientConnInterface) ConfigClient {
|
|
||||||
return &configClient{cc}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *configClient) Load(ctx context.Context, in *LoadRequest, opts ...grpc.CallOption) (*LoadResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(LoadResponse)
|
|
||||||
err := c.cc.Invoke(ctx, Config_Load_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *configClient) Save(ctx context.Context, in *SaveRequest, opts ...grpc.CallOption) (*SaveResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(SaveResponse)
|
|
||||||
err := c.cc.Invoke(ctx, Config_Save_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ConfigServer is the server API for Config service.
|
|
||||||
// All implementations must embed UnimplementedConfigServer
|
|
||||||
// for forward compatibility.
|
|
||||||
type ConfigServer interface {
|
|
||||||
Load(context.Context, *LoadRequest) (*LoadResponse, error)
|
|
||||||
Save(context.Context, *SaveRequest) (*SaveResponse, error)
|
|
||||||
mustEmbedUnimplementedConfigServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnimplementedConfigServer must be embedded to have
|
|
||||||
// forward compatible implementations.
|
|
||||||
//
|
|
||||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
|
||||||
// pointer dereference when methods are called.
|
|
||||||
type UnimplementedConfigServer struct{}
|
|
||||||
|
|
||||||
func (UnimplementedConfigServer) Load(context.Context, *LoadRequest) (*LoadResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Load not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedConfigServer) Save(context.Context, *SaveRequest) (*SaveResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Save not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedConfigServer) mustEmbedUnimplementedConfigServer() {}
|
|
||||||
func (UnimplementedConfigServer) testEmbeddedByValue() {}
|
|
||||||
|
|
||||||
// UnsafeConfigServer may be embedded to opt out of forward compatibility for this service.
|
|
||||||
// Use of this interface is not recommended, as added methods to ConfigServer will
|
|
||||||
// result in compilation errors.
|
|
||||||
type UnsafeConfigServer interface {
|
|
||||||
mustEmbedUnimplementedConfigServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterConfigServer(s grpc.ServiceRegistrar, srv ConfigServer) {
|
|
||||||
// If the following call pancis, it indicates UnimplementedConfigServer was
|
|
||||||
// embedded by pointer and is nil. This will cause panics if an
|
|
||||||
// unimplemented method is ever invoked, so we test this at initialization
|
|
||||||
// time to prevent it from happening at runtime later due to I/O.
|
|
||||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
|
||||||
t.testEmbeddedByValue()
|
|
||||||
}
|
|
||||||
s.RegisterService(&Config_ServiceDesc, srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Config_Load_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(LoadRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(ConfigServer).Load(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Config_Load_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(ConfigServer).Load(ctx, req.(*LoadRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Config_Save_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(SaveRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(ConfigServer).Save(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Config_Save_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(ConfigServer).Save(ctx, req.(*SaveRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Config_ServiceDesc is the grpc.ServiceDesc for Config service.
|
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
|
||||||
// and not to be introspected or modified (even as a copy)
|
|
||||||
var Config_ServiceDesc = grpc.ServiceDesc{
|
|
||||||
ServiceName: "service.Config",
|
|
||||||
HandlerType: (*ConfigServer)(nil),
|
|
||||||
Methods: []grpc.MethodDesc{
|
|
||||||
{
|
|
||||||
MethodName: "Load",
|
|
||||||
Handler: _Config_Load_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "Save",
|
|
||||||
Handler: _Config_Save_Handler,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Streams: []grpc.StreamDesc{},
|
|
||||||
Metadata: "service.proto",
|
|
||||||
}
|
|
||||||
26
proto/service_micro.pb.go
Normal file
26
proto/service_micro.pb.go
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// - protoc-gen-go-micro v3.10.4
|
||||||
|
// - protoc v6.33.4
|
||||||
|
// source: service.proto
|
||||||
|
|
||||||
|
package servicepb
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
client "go.unistack.org/micro/v4/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ConfigName = "Config"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ConfigClient interface {
|
||||||
|
Load(ctx context.Context, req *LoadRequest, opts ...client.CallOption) (*LoadResponse, error)
|
||||||
|
Save(ctx context.Context, req *SaveRequest, opts ...client.CallOption) (*SaveResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigServer interface {
|
||||||
|
Load(ctx context.Context, req *LoadRequest, rsp *LoadResponse) error
|
||||||
|
Save(ctx context.Context, req *SaveRequest, rsp *SaveResponse) error
|
||||||
|
}
|
||||||
14
service.go
14
service.go
@@ -5,7 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"dario.cat/mergo"
|
"dario.cat/mergo"
|
||||||
pbmicro "go.unistack.org/micro-config-service/v4/micro"
|
pbgrpc "go.unistack.org/micro-config-service/v4/grpc"
|
||||||
|
pbhttp "go.unistack.org/micro-config-service/v4/http"
|
||||||
pb "go.unistack.org/micro-config-service/v4/proto"
|
pb "go.unistack.org/micro-config-service/v4/proto"
|
||||||
"go.unistack.org/micro/v4/client"
|
"go.unistack.org/micro/v4/client"
|
||||||
"go.unistack.org/micro/v4/config"
|
"go.unistack.org/micro/v4/config"
|
||||||
@@ -19,7 +20,7 @@ var DefaultStructTag = "service"
|
|||||||
type serviceConfig struct {
|
type serviceConfig struct {
|
||||||
opts config.Options
|
opts config.Options
|
||||||
service string
|
service string
|
||||||
client pbmicro.ConfigClient
|
client pb.ConfigClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *serviceConfig) Options() config.Options {
|
func (c *serviceConfig) Options() config.Options {
|
||||||
@@ -71,7 +72,14 @@ func (c *serviceConfig) Init(opts ...config.Option) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
c.client = pbmicro.NewConfigClient(c.service, cli)
|
switch cli.String() {
|
||||||
|
case "http":
|
||||||
|
c.client = pbhttp.NewConfigClient(c.service, cli)
|
||||||
|
case "grpc":
|
||||||
|
c.client = pbgrpc.NewConfigClient(c.service, cli)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unknown client option")
|
||||||
|
}
|
||||||
|
|
||||||
if err := config.DefaultAfterInit(c.opts.Context, c); err != nil && !c.opts.AllowFail {
|
if err := config.DefaultAfterInit(c.opts.Context, c); err != nil && !c.opts.AllowFail {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user