diff --git a/client/circuit_breaker.go b/client/circuit_breaker.go index 653ec5d..541993c 100644 --- a/client/circuit_breaker.go +++ b/client/circuit_breaker.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/client/client.go b/client/client.go index 674d3e1..3cc1a0c 100644 --- a/client/client.go +++ b/client/client.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/client/retry.go b/client/retry.go index 370b856..7b6b448 100644 --- a/client/retry.go +++ b/client/retry.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/client/rpc_timeout.go b/client/rpc_timeout.go index b9a59d7..bd536fe 100644 --- a/client/rpc_timeout.go +++ b/client/rpc_timeout.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/client/suite.go b/client/suite.go index dfc2fac..8b851b3 100644 --- a/client/suite.go +++ b/client/suite.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/example/client/kitex_client.ini b/example/client/kitex_client.ini index f854243..1f93105 100644 --- a/example/client/kitex_client.ini +++ b/example/client/kitex_client.ini @@ -1,19 +1,23 @@ -[Timeout] +[ClientName/ServiceName] RPCTimeoutMS = 100 ConnTimeoutMS = 2000 -[Circuitbreaker] +[ClientName/ServiceName.Circuitbreaker.Echo] Enable = true ErrRate = 0.3 MinSample = 100 -[Retry] +[ClientName/ServiceName.Retry.*] Enable = true Type = 0 -[StopPolicy] +[ClientName/ServiceName.Retry.Echo] +Enable = true +Type = 1 + +[ClientName/ServiceName.Retry.*.FailurePolicy.StopPolicy] MaxRetryTimes = 2 MaxDurationMS = 1000 -[CBPolicy] +[ClientName/ServiceName.Retry.*.CBPolicy] ErrorRate = 0.2 \ No newline at end of file diff --git a/example/client/main.go b/example/client/main.go index 6044fc3..f2c9560 100644 --- a/example/client/main.go +++ b/example/client/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ const ( type MyParser struct{} // one example for custom parser +// if the type of client config is json or yaml,just using default parser func (p *MyParser) Decode(kind parser.ConfigType, data []byte, config interface{}) error { cfg, err := ini.Load(data) if err != nil { @@ -67,11 +68,11 @@ func (p *MyParser) Decode(kind parser.ConfigType, data []byte, config interface{ stop := &retry.StopPolicy{} cb := &retry.CBPolicy{} - cfg.Section("Timeout").MapTo(timeout) - cfg.Section("Circuitbreaker").MapTo(circ) - cfg.Section("Retry").MapTo(ret) - cfg.Section("StopPolicy").MapTo(stop) - cfg.Section("CBPolicy").MapTo(cb) + cfg.Section(key).MapTo(timeout) + cfg.Section("ClientName/ServiceName.Circuitbreaker.Echo").MapTo(circ) + cfg.Section("ClientName/ServiceName.Retry.*").MapTo(ret) + cfg.Section("ClientName/ServiceName.Retry.*.FailurePolicy.StopPolicy").MapTo(stop) + cfg.Section("ClientName/ServiceName.Retry.*.CBPolicy").MapTo(cb) stop.CBPolicy = *cb ret.FailurePolicy = &retry.FailurePolicy{ StopPolicy: *stop, diff --git a/example/server/kitex_server.ini b/example/server/kitex_server.ini index 846621b..6ecb48b 100644 --- a/example/server/kitex_server.ini +++ b/example/server/kitex_server.ini @@ -1,3 +1,3 @@ -[ServiceName] +[ServiceName.Limit] ConnectionLimit = 300 QPSLimit = 200 \ No newline at end of file diff --git a/example/server/main.go b/example/server/main.go index 711dfaa..6cfaa1b 100644 --- a/example/server/main.go +++ b/example/server/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -53,6 +53,7 @@ func (s *EchoImpl) Echo(ctx context.Context, req *api.Request) (resp *api.Respon type MyParser struct{} // one example for custom parser +// if the type of client config is json or yaml,just using default parser func (p *MyParser) Decode(kind parser.ConfigType, data []byte, config interface{}) error { cfg, err := ini.Load(data) if err != nil { @@ -62,7 +63,7 @@ func (p *MyParser) Decode(kind parser.ConfigType, data []byte, config interface{ sfm := make(parser.ServerFileManager, 0) sfc := &parser.ServerFileConfig{} - cfg.Section(serviceName).MapTo(sfc) + cfg.MapTo(sfc) sfm[key] = sfc v := config.(*parser.ServerFileManager) diff --git a/filewatcher/filewatcher.go b/filewatcher/filewatcher.go index 69818b9..dadf6f8 100644 --- a/filewatcher/filewatcher.go +++ b/filewatcher/filewatcher.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/mock/filewatcher_mock.go b/mock/filewatcher_mock.go index 35f57d5..8ea0c12 100644 --- a/mock/filewatcher_mock.go +++ b/mock/filewatcher_mock.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/monitor/monitor.go b/monitor/monitor.go index 09df905..04c6c1c 100644 --- a/monitor/monitor.go +++ b/monitor/monitor.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/monitor/monitor_test.go b/monitor/monitor_test.go index 9105b9d..9f936ce 100644 --- a/monitor/monitor_test.go +++ b/monitor/monitor_test.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/parser/client.go b/parser/client.go index 7a98800..a9e6c48 100644 --- a/parser/client.go +++ b/parser/client.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/parser/parser.go b/parser/parser.go index 305dae0..2b30b2d 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/parser/server.go b/parser/server.go index 0acf360..3d0dedf 100644 --- a/parser/server.go +++ b/parser/server.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ import "github.com/cloudwego/kitex/pkg/limiter" // ServerFileConfig is config of a service type ServerFileConfig struct { - Limit limiter.LimiterConfig `mapstructure:"limit" ini:"ServiceName"` + Limit limiter.LimiterConfig `mapstructure:"limit" ini:"ServiceName.Limit"` } // ServerFileManager is a map of service names to ServerFileConfig diff --git a/server/limit.go b/server/limit.go index 468121a..92d81e3 100644 --- a/server/limit.go +++ b/server/limit.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/server/server.go b/server/server.go index 673e637..cdf9f02 100644 --- a/server/server.go +++ b/server/server.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/server/suite.go b/server/suite.go index e4574ed..4732dde 100644 --- a/server/suite.go +++ b/server/suite.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/utils/set.go b/utils/set.go index 597f225..7b7cb3c 100644 --- a/utils/set.go +++ b/utils/set.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/utils/set_test.go b/utils/set_test.go index 1013b79..94ec404 100644 --- a/utils/set_test.go +++ b/utils/set_test.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/utils/utils.go b/utils/utils.go index 0eacd61..014c064 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -1,4 +1,4 @@ -// Copyright 2023 CloudWeGo Authors +// Copyright 2024 CloudWeGo Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.