Compare commits

..

1 Commits
master ... v3

Author SHA1 Message Date
Василий Толстов 0c71699f94 update deps
build / test (push) Failing after 1m25s Details
codeql / analyze (go) (push) Failing after 1m59s Details
build / lint (push) Successful in 9m20s Details
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-06 17:38:46 +03:00
11 changed files with 268 additions and 103 deletions

View File

@ -1,5 +1,3 @@
package service
//go:generate protoc -I./proto -I. --go_out=paths=source_relative:./proto proto/service.proto
//go:generate protoc -I./proto -I. --go-micro_out=components=micro,standalone=false,debug=true,paths=source_relative:./proto proto/service.proto
//go:generate protoc -I./proto -I. --go-micro_out=components=grpc,standalone=true,debug=true,paths=source_relative:./micro proto/service.proto
//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

14
go.mod
View File

@ -1,14 +1,20 @@
module go.unistack.org/micro-config-service/v4
module go.unistack.org/micro-config-service/v3
go 1.20
go 1.18
require (
dario.cat/mergo v1.0.0
go.unistack.org/micro/v4 v4.0.17
go.unistack.org/micro-server-http/v3 v3.11.11
go.unistack.org/micro/v3 v3.10.44
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0
)
require (
github.com/google/go-cmp v0.5.9 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 // indirect
)

21
go.sum
View File

@ -1,11 +1,24 @@
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
go.unistack.org/micro/v4 v4.0.17 h1:mF7uM+J4ILdG+1fcwzKYCwDlxhdbF/e1WnGzKKLnIXc=
go.unistack.org/micro/v4 v4.0.17/go.mod h1:ZDgU9931vm2l7X6RN/6UuwRIVp24GRdmQ7dKmegArk4=
go.unistack.org/micro-server-http/v3 v3.11.11 h1:t9uPcXwtNjeCy6fj6LGY7F4dmHMXZ96U9vqNzD4gb6A=
go.unistack.org/micro-server-http/v3 v3.11.11/go.mod h1:gCWne+4AHidpl6oYDRygkEXbC0N8V0LW+TKBdYMrzdk=
go.unistack.org/micro/v3 v3.10.44 h1:Vgyy9BrJOSdFvo29/klrgIBE/Nme9E8udPAljos34o0=
go.unistack.org/micro/v3 v3.10.44/go.mod h1:erMgt3Bl7vQQ0e9UpQyR5NlLiZ9pKeEJ9+1tfYFaqUg=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 h1:IR+hp6ypxjH24bkMfEJ0yHR21+gwPWdV+/IBrPQyn3k=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs=
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

31
micro/service_micro.pb.go Normal file
View File

@ -0,0 +1,31 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// versions:
// - protoc-gen-go-micro v3.10.2
// - protoc v3.21.12
// source: service.proto
package servicepb
import (
context "context"
proto "go.unistack.org/micro-config-service/v3/proto"
v3 "go.unistack.org/micro-server-http/v3"
client "go.unistack.org/micro/v3/client"
)
var (
ConfigName = "Config"
)
var (
ConfigServerEndpoints = []v3.EndpointMetadata{}
)
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
}

View File

@ -1,65 +1,64 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// protoc-gen-go-micro version: v4.0.2
// protoc-gen-go-micro version: v3.10.2
// source: service.proto
package servicepb
import (
context "context"
proto "go.unistack.org/micro-config-service/v4/proto"
client "go.unistack.org/micro/v4/client"
options "go.unistack.org/micro/v4/options"
server "go.unistack.org/micro/v4/server"
proto "go.unistack.org/micro-config-service/v3/proto"
client "go.unistack.org/micro/v3/client"
server "go.unistack.org/micro/v3/server"
)
type configServiceClient struct {
type configClient struct {
c client.Client
name string
}
func NewConfigServiceClient(name string, c client.Client) proto.ConfigServiceClient {
return &configServiceClient{c: c, name: name}
func NewConfigClient(name string, c client.Client) ConfigClient {
return &configClient{c: c, name: name}
}
func (c *configServiceClient) Load(ctx context.Context, req *proto.LoadRequest, opts ...options.Option) (*proto.LoadResponse, error) {
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, "ConfigService.Load", req), rsp, opts...)
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 *configServiceClient) Save(ctx context.Context, req *proto.SaveRequest, opts ...options.Option) (*proto.SaveResponse, error) {
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, "ConfigService.Save", req), rsp, opts...)
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 configServiceServer struct {
proto.ConfigServiceServer
type configServer struct {
ConfigServer
}
func (h *configServiceServer) Load(ctx context.Context, req *proto.LoadRequest, rsp *proto.LoadResponse) error {
return h.ConfigServiceServer.Load(ctx, req, rsp)
func (h *configServer) Load(ctx context.Context, req *proto.LoadRequest, rsp *proto.LoadResponse) error {
return h.ConfigServer.Load(ctx, req, rsp)
}
func (h *configServiceServer) Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.SaveResponse) error {
return h.ConfigServiceServer.Save(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 RegisterConfigServiceServer(s server.Server, sh proto.ConfigServiceServer, opts ...options.Option) error {
type configService interface {
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 ConfigService struct {
configService
type Config struct {
config
}
h := &configServiceServer{sh}
var nopts []options.Option
return s.Handle(&ConfigService{h}, append(nopts, opts...)...)
h := &configServer{sh}
var nopts []server.HandlerOption
return s.Handle(s.NewHandler(&Config{h}, append(nopts, opts...)...))
}

View File

@ -1,20 +1,20 @@
package service
import (
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/config"
)
type clientKey struct{}
// Client to call config service
func Client(c client.Client) options.Option {
return options.ContextOption(clientKey{}, c)
func Client(c client.Client) config.Option {
return config.SetOption(clientKey{}, c)
}
type serviceKey struct{}
// Service to which data load
func Service(s string) options.Option {
return options.ContextOption(serviceKey{}, s)
func Service(s string) config.Option {
return config.SetOption(serviceKey{}, s)
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc v4.23.4
// protoc v3.21.12
// source: service.proto
package servicepb
@ -221,19 +221,19 @@ var file_service_proto_rawDesc = []byte{
0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x0e, 0x0a, 0x0c, 0x53, 0x61,
0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x7d, 0x0a, 0x0d, 0x43, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x35, 0x0a, 0x04, 0x4c,
0x6f, 0x61, 0x64, 0x12, 0x14, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x6f,
0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x35, 0x0a, 0x04, 0x53, 0x61, 0x76, 0x65, 0x12, 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, 0x00, 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,
0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x76, 0x0a, 0x06, 0x43, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, 0x0a, 0x04, 0x4c, 0x6f, 0x61, 0x64, 0x12, 0x14, 0x2e, 0x73,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x6f, 0x61,
0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x04, 0x53,
0x61, 0x76, 0x65, 0x12, 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, 0x00, 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, 0x33, 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 (
@ -256,10 +256,10 @@ var file_service_proto_goTypes = []interface{}{
(*SaveResponse)(nil), // 3: service.SaveResponse
}
var file_service_proto_depIdxs = []int32{
0, // 0: service.ConfigService.Load:input_type -> service.LoadRequest
2, // 1: service.ConfigService.Save:input_type -> service.SaveRequest
1, // 2: service.ConfigService.Load:output_type -> service.LoadResponse
3, // 3: service.ConfigService.Save:output_type -> service.SaveResponse
0, // 0: service.Config.Load:input_type -> service.LoadRequest
2, // 1: service.Config.Save:input_type -> service.SaveRequest
1, // 2: service.Config.Load:output_type -> service.LoadResponse
3, // 3: service.Config.Save:output_type -> service.SaveResponse
2, // [2:4] is the sub-list for method output_type
0, // [0:2] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name

View File

@ -1,9 +1,9 @@
syntax = "proto3";
package service;
option go_package="go.unistack.org/micro-config-service/v4/proto;servicepb";
option go_package="go.unistack.org/micro-config-service/v3/proto;servicepb";
service ConfigService {
service Config {
rpc Load(LoadRequest) returns (LoadResponse) {};
rpc Save(SaveRequest) returns (SaveResponse) {};
}

146
proto/service_grpc.pb.go Normal file
View File

@ -0,0 +1,146 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v3.21.12
// 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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
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) {
out := new(LoadResponse)
err := c.cc.Invoke(ctx, Config_Load_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *configClient) Save(ctx context.Context, in *SaveRequest, opts ...grpc.CallOption) (*SaveResponse, error) {
out := new(SaveResponse)
err := c.cc.Invoke(ctx, Config_Save_FullMethodName, in, out, opts...)
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.
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() {}
// 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) {
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",
}

View File

@ -1,27 +0,0 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// versions:
// - protoc-gen-go-micro v4.0.2
// - protoc v4.23.4
// source: service.proto
package servicepb
import (
context "context"
_ "go.unistack.org/micro/v4/client"
options "go.unistack.org/micro/v4/options"
)
var (
ConfigServiceName = "ConfigService"
)
type ConfigServiceClient interface {
Load(ctx context.Context, req *LoadRequest, opts ...options.Option) (*LoadResponse, error)
Save(ctx context.Context, req *SaveRequest, opts ...options.Option) (*SaveResponse, error)
}
type ConfigServiceServer interface {
Load(ctx context.Context, req *LoadRequest, rsp *LoadResponse) error
Save(ctx context.Context, req *SaveRequest, rsp *SaveResponse) error
}

View File

@ -1,16 +1,15 @@
package service // import "go.unistack.org/micro-config-service/v4"
package service // import "go.unistack.org/micro-config-service/v3"
import (
"context"
"fmt"
"dario.cat/mergo"
pbmicro "go.unistack.org/micro-config-service/v4/micro"
pb "go.unistack.org/micro-config-service/v4/proto"
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/config"
"go.unistack.org/micro/v4/options"
rutil "go.unistack.org/micro/v4/util/reflect"
pbmicro "go.unistack.org/micro-config-service/v3/micro"
pb "go.unistack.org/micro-config-service/v3/proto"
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/config"
rutil "go.unistack.org/micro/v3/util/reflect"
)
var _ config.Config = &serviceConfig{}
@ -20,14 +19,14 @@ var DefaultStructTag = "service"
type serviceConfig struct {
opts config.Options
service string
client pb.ConfigServiceClient
client pbmicro.ConfigClient
}
func (c *serviceConfig) Options() config.Options {
return c.opts
}
func (c *serviceConfig) Init(opts ...options.Option) error {
func (c *serviceConfig) Init(opts ...config.Option) error {
if err := config.DefaultBeforeInit(c.opts.Context, c); err != nil && !c.opts.AllowFail {
return err
}
@ -72,7 +71,7 @@ func (c *serviceConfig) Init(opts ...options.Option) error {
return nil
}
c.client = pbmicro.NewConfigServiceClient(c.service, cli)
c.client = pbmicro.NewConfigClient(c.service, cli)
if err := config.DefaultAfterInit(c.opts.Context, c); err != nil && !c.opts.AllowFail {
return err
@ -81,7 +80,7 @@ func (c *serviceConfig) Init(opts ...options.Option) error {
return nil
}
func (c *serviceConfig) Load(ctx context.Context, opts ...options.Option) error {
func (c *serviceConfig) Load(ctx context.Context, opts ...config.LoadOption) error {
if err := config.DefaultBeforeLoad(ctx, c); err != nil && !c.opts.AllowFail {
return err
}
@ -132,7 +131,7 @@ func (c *serviceConfig) Load(ctx context.Context, opts ...options.Option) error
return nil
}
func (c *serviceConfig) Save(ctx context.Context, opts ...options.Option) error {
func (c *serviceConfig) Save(ctx context.Context, opts ...config.SaveOption) error {
if err := config.DefaultBeforeSave(ctx, c); err != nil && !c.opts.AllowFail {
return err
}
@ -167,11 +166,11 @@ func (c *serviceConfig) Name() string {
return c.opts.Name
}
func (c *serviceConfig) Watch(ctx context.Context, opts ...options.Option) (config.Watcher, error) {
func (c *serviceConfig) Watch(ctx context.Context, opts ...config.WatchOption) (config.Watcher, error) {
return nil, fmt.Errorf("not implemented")
}
func NewConfig(opts ...options.Option) *serviceConfig {
func NewConfig(opts ...config.Option) *serviceConfig {
options := config.NewOptions(opts...)
if len(options.StructTag) == 0 {
options.StructTag = DefaultStructTag