Skip to content

Commit 1fda0a0

Browse files
committed
chore: update core v0.12.0
1 parent 4cf44fd commit 1fda0a0

File tree

7 files changed

+271
-70
lines changed

7 files changed

+271
-70
lines changed

client_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ func TestClient_ProduceWithTracing(t *testing.T) {
2323
addrs := strings.Split(os.Getenv("KAFKA_ADDR"), ",")
2424
factory, cleanup := provideFactory(factoryIn{
2525
Logger: log.NewNopLogger(),
26-
Conf: config.MapAdapter{"kafka": map[string]Config{
27-
"default": {
28-
SeedBrokers: addrs,
29-
DefaultProduceTopic: "tracing",
26+
Conf: config.MapAdapter{"kafka": map[string]interface{}{
27+
"default": map[string]interface{}{
28+
"seed_brokers": addrs,
29+
"default_produce_topic": "tracing",
3030
},
3131
}},
3232
}, func(name string, config *Config) {})
@@ -64,10 +64,10 @@ func TestClient_ProduceWithOutTracing(t *testing.T) {
6464
addrs := strings.Split(os.Getenv("KAFKA_ADDR"), ",")
6565
factory, cleanup := provideFactory(factoryIn{
6666
Logger: log.NewNopLogger(),
67-
Conf: config.MapAdapter{"kafka": map[string]Config{
68-
"default": {
69-
SeedBrokers: addrs,
70-
DefaultProduceTopic: "tracing",
67+
Conf: config.MapAdapter{"kafka": map[string]interface{}{
68+
"default": map[string]interface{}{
69+
"seed_brokers": addrs,
70+
"default_produce_topic": "tracing",
7171
},
7272
}},
7373
}, func(name string, config *Config) {})

config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ type Config struct {
108108
AutocommitMarks bool `json:"autocommit_marks" yaml:"autocommit_marks"`
109109
AutocommitInterval time.Duration `json:"autocommit_interval" yaml:"autocommit_interval"`
110110
CommitCallback func(*kgo.Client, *kmsg.OffsetCommitRequest, *kmsg.OffsetCommitResponse, error) `json:"-" yaml:"-"`
111+
112+
// Options allows users to directly use the latest options without waiting for otfranz adaptation.
113+
Options []kgo.Opt `json:"-" yaml:"-"`
111114
}
112115

113116
func fromConfig(conf Config) (opts []kgo.Opt) {
@@ -335,5 +338,7 @@ func fromConfig(conf Config) (opts []kgo.Opt) {
335338
if conf.CommitCallback != nil {
336339
opts = append(opts, kgo.AutoCommitCallback(conf.CommitCallback))
337340
}
341+
342+
opts = append(opts, conf.Options...)
338343
return
339344
}

config_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ func Test_fromConfig(t *testing.T) {
7474

7575
func Test_Config_Unmarshal(t *testing.T) {
7676
conf := Config{}
77-
kf := config.MapAdapter{"kafka": map[string]Config{
78-
"default": {
79-
SeedBrokers: []string{"foo"},
77+
kf := config.MapAdapter{"kafka": map[string]interface{}{
78+
"default": map[string]interface{}{
79+
"seed_brokers": []string{"foo"},
8080
},
8181
}}
8282

dependency_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ func TestProvideFactory(t *testing.T) {
2828
addrs := strings.Split(os.Getenv("KAFKA_ADDR"), ",")
2929
factory, cleanup := provideFactory(factoryIn{
3030
Conf: config.MapAdapter{
31-
"kafka": map[string]Config{
32-
"default": {
33-
SeedBrokers: addrs,
34-
Topics: []string{"test"},
31+
"kafka": map[string]interface{}{
32+
"default": map[string]interface{}{
33+
"seed_brokers": addrs,
34+
"topics": []string{"test"},
3535
},
36-
"alternative": {
37-
SeedBrokers: addrs,
38-
Topics: []string{"test"},
36+
"alternative": map[string]interface{}{
37+
"seed_brokers": addrs,
38+
"topics": []string{"test"},
3939
},
4040
},
4141
},
@@ -64,14 +64,14 @@ func TestProvideKafka(t *testing.T) {
6464
reloadable: c.reloadable,
6565
})(factoryIn{
6666
Logger: log.NewNopLogger(),
67-
Conf: config.MapAdapter{"kafka": map[string]Config{
68-
"default": {
69-
SeedBrokers: nil,
70-
Topics: []string{"test"},
67+
Conf: config.MapAdapter{"kafka": map[string]interface{}{
68+
"default": map[string]interface{}{
69+
"seed_brokers": nil,
70+
"topics": []string{"test"},
7171
},
72-
"alternative": {
73-
SeedBrokers: nil,
74-
Topics: []string{"test"},
72+
"alternative": map[string]interface{}{
73+
"seed_brokers": nil,
74+
"topics": []string{"test"},
7575
},
7676
}},
7777
Dispatcher: dispatcher,
@@ -97,12 +97,12 @@ func TestProduceAndConsume(t *testing.T) {
9797
addrs := strings.Split(os.Getenv("KAFKA_ADDR"), ",")
9898
factory, cleanup := provideFactory(factoryIn{
9999
Logger: log.NewNopLogger(),
100-
Conf: config.MapAdapter{"kafka": map[string]Config{
101-
"default": {
102-
SeedBrokers: addrs,
103-
DefaultProduceTopic: "test",
104-
Topics: []string{"test"},
105-
Group: "test",
100+
Conf: config.MapAdapter{"kafka": map[string]interface{}{
101+
"default": map[string]interface{}{
102+
"seed_brokers": addrs,
103+
"default_produce_topic": "test",
104+
"topics": []string{"test"},
105+
"group": "test",
106106
},
107107
}},
108108
}, func(name string, config *Config) {})

example_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ func Example() {
2424
"level": "none",
2525
},
2626
"kafka": map[string]interface{}{
27-
"default": otfranz.Config{
28-
SeedBrokers: brokers,
29-
DefaultProduceTopic: "example",
30-
Topics: []string{"example"},
31-
Group: "test",
27+
"default": map[string]interface{}{
28+
"seed_brokers": brokers,
29+
"default_produce_topic": "example",
30+
"topics": []string{"example"},
31+
"group": "test",
3232
},
3333
},
3434
}

go.mod

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module github.com/DoNewsCode/core-otfranz
33
go 1.17
44

55
require (
6-
github.com/DoNewsCode/core v0.11.1
6+
github.com/DoNewsCode/core v0.12.0
77
github.com/go-kit/log v0.2.0
8-
github.com/knadh/koanf v0.15.0
8+
github.com/knadh/koanf v1.4.0
99
github.com/oklog/run v1.1.0
1010
github.com/opentracing/opentracing-go v1.2.0
1111
github.com/stretchr/testify v1.7.0
@@ -15,28 +15,30 @@ require (
1515

1616
require (
1717
github.com/davecgh/go-spew v1.1.1 // indirect
18-
github.com/fsnotify/fsnotify v1.4.9 // indirect
18+
github.com/fsnotify/fsnotify v1.5.1 // indirect
1919
github.com/go-kit/kit v0.12.0 // indirect
2020
github.com/go-logfmt/logfmt v0.5.1 // indirect
2121
github.com/golang/protobuf v1.5.2 // indirect
2222
github.com/gorilla/mux v1.8.0 // indirect
2323
github.com/inconshreveable/mousetrap v1.0.0 // indirect
2424
github.com/klauspost/compress v1.13.6 // indirect
25-
github.com/mitchellh/mapstructure v1.4.2 // indirect
25+
github.com/mitchellh/copystructure v1.2.0 // indirect
26+
github.com/mitchellh/mapstructure v1.4.3 // indirect
27+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
2628
github.com/pierrec/lz4/v4 v4.1.11 // indirect
2729
github.com/pkg/errors v0.9.1 // indirect
2830
github.com/pmezard/go-difflib v1.0.0 // indirect
2931
github.com/robfig/cron/v3 v3.0.1 // indirect
30-
github.com/spf13/cobra v1.1.3 // indirect
32+
github.com/spf13/cobra v1.3.0 // indirect
3133
github.com/spf13/pflag v1.0.5 // indirect
3234
github.com/twmb/go-rbtree v1.0.0 // indirect
3335
go.uber.org/dig v1.13.0 // indirect
34-
golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9 // indirect
36+
golang.org/x/net v0.0.0-20220114011407-0dd24b26b47d // indirect
3537
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
36-
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678 // indirect
38+
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
3739
golang.org/x/text v0.3.7 // indirect
38-
google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect
39-
google.golang.org/grpc v1.40.0 // indirect
40+
google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5 // indirect
41+
google.golang.org/grpc v1.43.0 // indirect
4042
google.golang.org/protobuf v1.27.1 // indirect
4143
gopkg.in/yaml.v2 v2.4.0 // indirect
4244
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect

0 commit comments

Comments
 (0)