Skip to content

Commit

Permalink
chore: modify ini and license
Browse files Browse the repository at this point in the history
  • Loading branch information
notacommonperson committed Jan 21, 2024
1 parent 3b4488b commit 6ce195b
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion client/circuit_breaker.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion client/retry.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion client/rpc_timeout.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion client/suite.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
14 changes: 9 additions & 5 deletions example/client/kitex_client.ini
Original file line number Diff line number Diff line change
@@ -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
13 changes: 7 additions & 6 deletions example/client/main.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion example/server/kitex_server.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[ServiceName]
[ServiceName.Limit]
ConnectionLimit = 300
QPSLimit = 200
5 changes: 3 additions & 2 deletions example/server/main.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion filewatcher/filewatcher.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion mock/filewatcher_mock.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion monitor/monitor.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion monitor/monitor_test.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion parser/client.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion parser/parser.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions parser/server.go
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/limit.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion server/suite.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion utils/set.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion utils/set_test.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 6ce195b

Please sign in to comment.