Compare commits
45 Commits
Author | SHA1 | Date | |
---|---|---|---|
355bb374fe | |||
bf925ed29f | |||
1f1d169fb7 | |||
|
f2669fc9fe | ||
8bc98510eb | |||
ed0f35133d | |||
c36b9e002f | |||
106ef7ba77 | |||
67d5795e89 | |||
29507e05c2 | |||
e1824d489f | |||
d04faa57f4 | |||
|
ca4217c39b | ||
ee7b577836 | |||
|
ee00f5b23a | ||
cb8eefb5cc | |||
|
5f77c1bcd4 | ||
c3254e64b0 | |||
|
625714c64f | ||
0bead0e5e5 | |||
|
98bc5e8f2d | ||
e54ebcf3b8 | |||
|
caa3516c41 | ||
9b97c43cd2 | |||
|
77b20afc4a | ||
42d74ac2d3 | |||
|
5a2b527e50 | ||
d135d10118 | |||
|
dfd95b422b | ||
8449ef31ff | |||
|
5cb00f71ae | ||
50b15cffbe | |||
|
64bc5fbbd0 | ||
7767cfb631 | |||
|
c987c7b8ce | ||
fcc32e1858 | |||
|
d35c84de91 | ||
259428c24f | |||
|
d350e6eaec | ||
145dd9efd2 | |||
|
c07c3dea24 | ||
3e391f0cda | |||
821ac7b986 | |||
|
d07cc91d74 | ||
|
dd31aa13b7 |
@@ -1,3 +1,5 @@
|
|||||||
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 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
|
||||||
|
18
go.mod
18
go.mod
@@ -1,24 +1,16 @@
|
|||||||
module go.unistack.org/micro-config-service/v4
|
module go.unistack.org/micro-config-service/v4
|
||||||
|
|
||||||
go 1.22.0
|
go 1.21
|
||||||
|
|
||||||
|
toolchain go1.23.4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
dario.cat/mergo v1.0.1
|
dario.cat/mergo v1.0.1
|
||||||
go.unistack.org/micro/v4 v4.1.3
|
go.unistack.org/micro/v4 v4.0.17
|
||||||
google.golang.org/grpc v1.71.0
|
google.golang.org/protobuf v1.35.2
|
||||||
google.golang.org/protobuf v1.36.5
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ash3in/uuidv8 v1.2.0 // indirect
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/matoous/go-nanoid v1.5.1 // indirect
|
|
||||||
github.com/spf13/cast v1.7.1 // indirect
|
|
||||||
go.unistack.org/micro-proto/v4 v4.1.0 // indirect
|
|
||||||
golang.org/x/net v0.37.0 // indirect
|
|
||||||
golang.org/x/sys v0.31.0 // indirect
|
|
||||||
golang.org/x/text v0.23.0 // indirect
|
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
|
||||||
)
|
)
|
||||||
|
55
go.sum
55
go.sum
@@ -1,59 +1,10 @@
|
|||||||
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
|
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
|
||||||
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
|
||||||
github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=
|
|
||||||
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
|
|
||||||
github.com/ash3in/uuidv8 v1.2.0 h1:2oogGdtCPwaVtyvPPGin4TfZLtOGE5F+W++E880G6SI=
|
|
||||||
github.com/ash3in/uuidv8 v1.2.0/go.mod h1:BnU0wJBxnzdEKmVg4xckBkD+VZuecTFTUP3M0dWgyY4=
|
|
||||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
|
||||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
|
||||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
|
||||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
|
||||||
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/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
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=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
go.unistack.org/micro/v4 v4.0.17 h1:mF7uM+J4ILdG+1fcwzKYCwDlxhdbF/e1WnGzKKLnIXc=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
go.unistack.org/micro/v4 v4.0.17/go.mod h1:ZDgU9931vm2l7X6RN/6UuwRIVp24GRdmQ7dKmegArk4=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
|
||||||
github.com/matoous/go-nanoid v1.5.1 h1:aCjdvTyO9LLnTIi0fgdXhOPPvOHjpXN6Ik9DaNjIct4=
|
|
||||||
github.com/matoous/go-nanoid v1.5.1/go.mod h1:zyD2a71IubI24efhpvkJz+ZwfwagzgSO6UNiFsZKN7U=
|
|
||||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
|
||||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
|
||||||
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
|
|
||||||
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
|
||||||
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
|
|
||||||
go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE=
|
|
||||||
go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE=
|
|
||||||
go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY=
|
|
||||||
go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk=
|
|
||||||
go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0=
|
|
||||||
go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc=
|
|
||||||
go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8=
|
|
||||||
go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys=
|
|
||||||
go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A=
|
|
||||||
go.unistack.org/micro-proto/v4 v4.1.0 h1:qPwL2n/oqh9RE3RTTDgt28XK3QzV597VugQPaw9lKUk=
|
|
||||||
go.unistack.org/micro-proto/v4 v4.1.0/go.mod h1:ArmK7o+uFvxSY3dbJhKBBX4Pm1rhWdLEFf3LxBrMtec=
|
|
||||||
go.unistack.org/micro/v4 v4.1.3 h1:9QHiLHBTfPtfKyoY3HsLPNVSK0wlAAoMV+9saLz2iR4=
|
|
||||||
go.unistack.org/micro/v4 v4.1.3/go.mod h1:lr3oYED8Ay1vjK68QqRw30QOtdk/ffpZqMFDasOUhKw=
|
|
||||||
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
|
|
||||||
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
|
|
||||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
|
||||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
||||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
|
||||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241216192217-9240e9c98484 h1:Z7FRVJPSMaHQxD0uXU8WdgFh8PseLM8Q8NzhnpMrBhQ=
|
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241216192217-9240e9c98484/go.mod h1:lcTa1sDdWEIHMWlITnIczmw5w60CF9ffkb8Z+DVmmjA=
|
|
||||||
google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A=
|
|
||||||
google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
|
|
||||||
google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU=
|
|
||||||
google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
@@ -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
|
|
||||||
}
|
|
@@ -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: v4.0.2
|
||||||
// source: service.proto
|
// source: service.proto
|
||||||
|
|
||||||
package servicepb
|
package servicepb
|
||||||
@@ -8,56 +8,58 @@ import (
|
|||||||
context "context"
|
context "context"
|
||||||
proto "go.unistack.org/micro-config-service/v4/proto"
|
proto "go.unistack.org/micro-config-service/v4/proto"
|
||||||
client "go.unistack.org/micro/v4/client"
|
client "go.unistack.org/micro/v4/client"
|
||||||
|
options "go.unistack.org/micro/v4/options"
|
||||||
server "go.unistack.org/micro/v4/server"
|
server "go.unistack.org/micro/v4/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
type configClient struct {
|
type configServiceClient struct {
|
||||||
c client.Client
|
c client.Client
|
||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfigClient(name string, c client.Client) ConfigClient {
|
func NewConfigServiceClient(name string, c client.Client) proto.ConfigServiceClient {
|
||||||
return &configClient{c: c, name: name}
|
return &configServiceClient{c: c, name: name}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *configClient) Load(ctx context.Context, req *proto.LoadRequest, opts ...client.CallOption) (*proto.LoadResponse, error) {
|
func (c *configServiceClient) Load(ctx context.Context, req *proto.LoadRequest, opts ...options.Option) (*proto.LoadResponse, error) {
|
||||||
rsp := &proto.LoadResponse{}
|
rsp := &proto.LoadResponse{}
|
||||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Config.Load", req), rsp, opts...)
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "ConfigService.Load", req), rsp, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rsp, nil
|
return rsp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *configClient) Save(ctx context.Context, req *proto.SaveRequest, opts ...client.CallOption) (*proto.SaveResponse, error) {
|
func (c *configServiceClient) Save(ctx context.Context, req *proto.SaveRequest, opts ...options.Option) (*proto.SaveResponse, error) {
|
||||||
rsp := &proto.SaveResponse{}
|
rsp := &proto.SaveResponse{}
|
||||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Config.Save", req), rsp, opts...)
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "ConfigService.Save", req), rsp, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rsp, nil
|
return rsp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type configServer struct {
|
type configServiceServer struct {
|
||||||
ConfigServer
|
proto.ConfigServiceServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *configServer) Load(ctx context.Context, req *proto.LoadRequest, rsp *proto.LoadResponse) error {
|
func (h *configServiceServer) Load(ctx context.Context, req *proto.LoadRequest, rsp *proto.LoadResponse) error {
|
||||||
return h.ConfigServer.Load(ctx, req, rsp)
|
return h.ConfigServiceServer.Load(ctx, req, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *configServer) Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.SaveResponse) error {
|
func (h *configServiceServer) Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.SaveResponse) error {
|
||||||
return h.ConfigServer.Save(ctx, req, rsp)
|
return h.ConfigServiceServer.Save(ctx, req, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterConfigServer(s server.Server, sh ConfigServer, opts ...server.HandlerOption) error {
|
func RegisterConfigServiceServer(s server.Server, sh proto.ConfigServiceServer, opts ...options.Option) error {
|
||||||
type config interface {
|
type configService 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
|
||||||
}
|
}
|
||||||
type Config struct {
|
type ConfigService struct {
|
||||||
config
|
configService
|
||||||
}
|
}
|
||||||
h := &configServer{sh}
|
h := &configServiceServer{sh}
|
||||||
return s.Handle(s.NewHandler(&Config{h}, opts...))
|
var nopts []options.Option
|
||||||
|
return s.Handle(&ConfigService{h}, append(nopts, opts...)...)
|
||||||
}
|
}
|
||||||
|
10
options.go
10
options.go
@@ -2,19 +2,19 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go.unistack.org/micro/v4/client"
|
"go.unistack.org/micro/v4/client"
|
||||||
"go.unistack.org/micro/v4/config"
|
"go.unistack.org/micro/v4/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
type clientKey struct{}
|
type clientKey struct{}
|
||||||
|
|
||||||
// Client to call config service
|
// Client to call config service
|
||||||
func Client(c client.Client) config.Option {
|
func Client(c client.Client) options.Option {
|
||||||
return config.SetOption(clientKey{}, c)
|
return options.ContextOption(clientKey{}, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
type serviceKey struct{}
|
type serviceKey struct{}
|
||||||
|
|
||||||
// Service to which data load
|
// Service to which data load
|
||||||
func Service(s string) config.Option {
|
func Service(s string) options.Option {
|
||||||
return config.SetOption(serviceKey{}, s)
|
return options.ContextOption(serviceKey{}, s)
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// 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 v4.23.4
|
||||||
// source: service.proto
|
// source: service.proto
|
||||||
|
|
||||||
package servicepb
|
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,
|
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,
|
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,
|
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, 0x76, 0x0a, 0x06, 0x43, 0x6f,
|
0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x7d, 0x0a, 0x0d, 0x43, 0x6f,
|
||||||
0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, 0x0a, 0x04, 0x4c, 0x6f, 0x61, 0x64, 0x12, 0x14, 0x2e, 0x73,
|
0x6e, 0x66, 0x69, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x35, 0x0a, 0x04, 0x4c,
|
||||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65,
|
0x6f, 0x61, 0x64, 0x12, 0x14, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x6f,
|
||||||
0x73, 0x74, 0x1a, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4c, 0x6f, 0x61,
|
0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x76,
|
||||||
0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x35, 0x0a, 0x04, 0x53,
|
0x69, 0x63, 0x65, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||||
0x61, 0x76, 0x65, 0x12, 0x14, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x61,
|
0x22, 0x00, 0x12, 0x35, 0x0a, 0x04, 0x53, 0x61, 0x76, 0x65, 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, 0x53, 0x61, 0x76, 0x65, 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, 0x53, 0x61, 0x76, 0x65, 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, 0x00, 0x42, 0x39, 0x5a, 0x37, 0x67, 0x6f, 0x2e,
|
||||||
0x6b, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x66,
|
0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x6d, 0x69, 0x63,
|
||||||
0x69, 0x67, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x34, 0x2f, 0x70, 0x72,
|
0x72, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||||
0x6f, 0x74, 0x6f, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70,
|
0x65, 0x2f, 0x76, 0x34, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x69,
|
||||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x63, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -256,10 +256,10 @@ var file_service_proto_goTypes = []interface{}{
|
|||||||
(*SaveResponse)(nil), // 3: service.SaveResponse
|
(*SaveResponse)(nil), // 3: service.SaveResponse
|
||||||
}
|
}
|
||||||
var file_service_proto_depIdxs = []int32{
|
var file_service_proto_depIdxs = []int32{
|
||||||
0, // 0: service.Config.Load:input_type -> service.LoadRequest
|
0, // 0: service.ConfigService.Load:input_type -> service.LoadRequest
|
||||||
2, // 1: service.Config.Save:input_type -> service.SaveRequest
|
2, // 1: service.ConfigService.Save:input_type -> service.SaveRequest
|
||||||
1, // 2: service.Config.Load:output_type -> service.LoadResponse
|
1, // 2: service.ConfigService.Load:output_type -> service.LoadResponse
|
||||||
3, // 3: service.Config.Save:output_type -> service.SaveResponse
|
3, // 3: service.ConfigService.Save:output_type -> service.SaveResponse
|
||||||
2, // [2:4] is the sub-list for method output_type
|
2, // [2:4] is the sub-list for method output_type
|
||||||
0, // [0:2] is the sub-list for method input_type
|
0, // [0:2] is the sub-list for method input_type
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
0, // [0:0] is the sub-list for extension type_name
|
||||||
|
@@ -3,7 +3,7 @@ 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";
|
||||||
|
|
||||||
service Config {
|
service ConfigService {
|
||||||
rpc Load(LoadRequest) returns (LoadResponse) {};
|
rpc Load(LoadRequest) returns (LoadResponse) {};
|
||||||
rpc Save(SaveRequest) returns (SaveResponse) {};
|
rpc Save(SaveRequest) returns (SaveResponse) {};
|
||||||
}
|
}
|
||||||
|
@@ -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",
|
|
||||||
}
|
|
27
proto/service_micro.pb.go
Normal file
27
proto/service_micro.pb.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// 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
|
||||||
|
}
|
34
service.go
34
service.go
@@ -1,4 +1,4 @@
|
|||||||
package service
|
package service // import "go.unistack.org/micro-config-service/v4"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
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"
|
||||||
|
"go.unistack.org/micro/v4/options"
|
||||||
rutil "go.unistack.org/micro/v4/util/reflect"
|
rutil "go.unistack.org/micro/v4/util/reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,20 +20,23 @@ var DefaultStructTag = "service"
|
|||||||
type serviceConfig struct {
|
type serviceConfig struct {
|
||||||
opts config.Options
|
opts config.Options
|
||||||
service string
|
service string
|
||||||
client pbmicro.ConfigClient
|
client pb.ConfigServiceClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *serviceConfig) Options() config.Options {
|
func (c *serviceConfig) Options() config.Options {
|
||||||
return c.opts
|
return c.opts
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *serviceConfig) Init(opts ...config.Option) error {
|
func (c *serviceConfig) Init(opts ...options.Option) error {
|
||||||
if err := config.DefaultBeforeInit(c.opts.Context, c); err != nil && !c.opts.AllowFail {
|
var err error
|
||||||
|
if err = config.DefaultBeforeInit(c.opts.Context, c); err != nil && !c.opts.AllowFail {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(&c.opts)
|
if err = o(&c.opts); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var cli client.Client
|
var cli client.Client
|
||||||
@@ -46,12 +50,12 @@ func (c *serviceConfig) Init(opts ...config.Option) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if cli == nil {
|
if cli == nil {
|
||||||
err := fmt.Errorf("missing client option")
|
err = fmt.Errorf("missing client option")
|
||||||
if !c.opts.AllowFail {
|
if !c.opts.AllowFail {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,28 +63,28 @@ func (c *serviceConfig) Init(opts ...config.Option) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.service == "" {
|
if c.service == "" {
|
||||||
err := fmt.Errorf("missing Service option")
|
err = fmt.Errorf("missing Service option")
|
||||||
if !c.opts.AllowFail {
|
if !c.opts.AllowFail {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
c.client = pbmicro.NewConfigClient(c.service, cli)
|
c.client = pbmicro.NewConfigServiceClient(c.service, cli)
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *serviceConfig) Load(ctx context.Context, opts ...config.LoadOption) error {
|
func (c *serviceConfig) Load(ctx context.Context, opts ...options.Option) error {
|
||||||
if err := config.DefaultBeforeLoad(ctx, c); err != nil && !c.opts.AllowFail {
|
if err := config.DefaultBeforeLoad(ctx, c); err != nil && !c.opts.AllowFail {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -131,7 +135,7 @@ func (c *serviceConfig) Load(ctx context.Context, opts ...config.LoadOption) err
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *serviceConfig) Save(ctx context.Context, opts ...config.SaveOption) error {
|
func (c *serviceConfig) Save(ctx context.Context, opts ...options.Option) error {
|
||||||
if err := config.DefaultBeforeSave(ctx, c); err != nil && !c.opts.AllowFail {
|
if err := config.DefaultBeforeSave(ctx, c); err != nil && !c.opts.AllowFail {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -166,11 +170,11 @@ func (c *serviceConfig) Name() string {
|
|||||||
return c.opts.Name
|
return c.opts.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *serviceConfig) Watch(ctx context.Context, opts ...config.WatchOption) (config.Watcher, error) {
|
func (c *serviceConfig) Watch(ctx context.Context, opts ...options.Option) (config.Watcher, error) {
|
||||||
return nil, fmt.Errorf("not implemented")
|
return nil, fmt.Errorf("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig(opts ...config.Option) *serviceConfig {
|
func NewConfig(opts ...options.Option) *serviceConfig {
|
||||||
options := config.NewOptions(opts...)
|
options := config.NewOptions(opts...)
|
||||||
if len(options.StructTag) == 0 {
|
if len(options.StructTag) == 0 {
|
||||||
options.StructTag = DefaultStructTag
|
options.StructTag = DefaultStructTag
|
||||||
|
Reference in New Issue
Block a user