Skip to content

Commit

Permalink
chore: update core v0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GGXXLL committed Jan 21, 2022
1 parent 4cf44fd commit 1fda0a0
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 70 deletions.
16 changes: 8 additions & 8 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func TestClient_ProduceWithTracing(t *testing.T) {
addrs := strings.Split(os.Getenv("KAFKA_ADDR"), ",")
factory, cleanup := provideFactory(factoryIn{
Logger: log.NewNopLogger(),
Conf: config.MapAdapter{"kafka": map[string]Config{
"default": {
SeedBrokers: addrs,
DefaultProduceTopic: "tracing",
Conf: config.MapAdapter{"kafka": map[string]interface{}{
"default": map[string]interface{}{
"seed_brokers": addrs,
"default_produce_topic": "tracing",
},
}},
}, func(name string, config *Config) {})
Expand Down Expand Up @@ -64,10 +64,10 @@ func TestClient_ProduceWithOutTracing(t *testing.T) {
addrs := strings.Split(os.Getenv("KAFKA_ADDR"), ",")
factory, cleanup := provideFactory(factoryIn{
Logger: log.NewNopLogger(),
Conf: config.MapAdapter{"kafka": map[string]Config{
"default": {
SeedBrokers: addrs,
DefaultProduceTopic: "tracing",
Conf: config.MapAdapter{"kafka": map[string]interface{}{
"default": map[string]interface{}{
"seed_brokers": addrs,
"default_produce_topic": "tracing",
},
}},
}, func(name string, config *Config) {})
Expand Down
5 changes: 5 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ type Config struct {
AutocommitMarks bool `json:"autocommit_marks" yaml:"autocommit_marks"`
AutocommitInterval time.Duration `json:"autocommit_interval" yaml:"autocommit_interval"`
CommitCallback func(*kgo.Client, *kmsg.OffsetCommitRequest, *kmsg.OffsetCommitResponse, error) `json:"-" yaml:"-"`

// Options allows users to directly use the latest options without waiting for otfranz adaptation.
Options []kgo.Opt `json:"-" yaml:"-"`
}

func fromConfig(conf Config) (opts []kgo.Opt) {
Expand Down Expand Up @@ -335,5 +338,7 @@ func fromConfig(conf Config) (opts []kgo.Opt) {
if conf.CommitCallback != nil {
opts = append(opts, kgo.AutoCommitCallback(conf.CommitCallback))
}

opts = append(opts, conf.Options...)
return
}
6 changes: 3 additions & 3 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func Test_fromConfig(t *testing.T) {

func Test_Config_Unmarshal(t *testing.T) {
conf := Config{}
kf := config.MapAdapter{"kafka": map[string]Config{
"default": {
SeedBrokers: []string{"foo"},
kf := config.MapAdapter{"kafka": map[string]interface{}{
"default": map[string]interface{}{
"seed_brokers": []string{"foo"},
},
}}

Expand Down
40 changes: 20 additions & 20 deletions dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ func TestProvideFactory(t *testing.T) {
addrs := strings.Split(os.Getenv("KAFKA_ADDR"), ",")
factory, cleanup := provideFactory(factoryIn{
Conf: config.MapAdapter{
"kafka": map[string]Config{
"default": {
SeedBrokers: addrs,
Topics: []string{"test"},
"kafka": map[string]interface{}{
"default": map[string]interface{}{
"seed_brokers": addrs,
"topics": []string{"test"},
},
"alternative": {
SeedBrokers: addrs,
Topics: []string{"test"},
"alternative": map[string]interface{}{
"seed_brokers": addrs,
"topics": []string{"test"},
},
},
},
Expand Down Expand Up @@ -64,14 +64,14 @@ func TestProvideKafka(t *testing.T) {
reloadable: c.reloadable,
})(factoryIn{
Logger: log.NewNopLogger(),
Conf: config.MapAdapter{"kafka": map[string]Config{
"default": {
SeedBrokers: nil,
Topics: []string{"test"},
Conf: config.MapAdapter{"kafka": map[string]interface{}{
"default": map[string]interface{}{
"seed_brokers": nil,
"topics": []string{"test"},
},
"alternative": {
SeedBrokers: nil,
Topics: []string{"test"},
"alternative": map[string]interface{}{
"seed_brokers": nil,
"topics": []string{"test"},
},
}},
Dispatcher: dispatcher,
Expand All @@ -97,12 +97,12 @@ func TestProduceAndConsume(t *testing.T) {
addrs := strings.Split(os.Getenv("KAFKA_ADDR"), ",")
factory, cleanup := provideFactory(factoryIn{
Logger: log.NewNopLogger(),
Conf: config.MapAdapter{"kafka": map[string]Config{
"default": {
SeedBrokers: addrs,
DefaultProduceTopic: "test",
Topics: []string{"test"},
Group: "test",
Conf: config.MapAdapter{"kafka": map[string]interface{}{
"default": map[string]interface{}{
"seed_brokers": addrs,
"default_produce_topic": "test",
"topics": []string{"test"},
"group": "test",
},
}},
}, func(name string, config *Config) {})
Expand Down
10 changes: 5 additions & 5 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ func Example() {
"level": "none",
},
"kafka": map[string]interface{}{
"default": otfranz.Config{
SeedBrokers: brokers,
DefaultProduceTopic: "example",
Topics: []string{"example"},
Group: "test",
"default": map[string]interface{}{
"seed_brokers": brokers,
"default_produce_topic": "example",
"topics": []string{"example"},
"group": "test",
},
},
}
Expand Down
20 changes: 11 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/DoNewsCode/core-otfranz
go 1.17

require (
github.com/DoNewsCode/core v0.11.1
github.com/DoNewsCode/core v0.12.0
github.com/go-kit/log v0.2.0
github.com/knadh/koanf v0.15.0
github.com/knadh/koanf v1.4.0
github.com/oklog/run v1.1.0
github.com/opentracing/opentracing-go v1.2.0
github.com/stretchr/testify v1.7.0
Expand All @@ -15,28 +15,30 @@ require (

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/pierrec/lz4/v4 v4.1.11 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/spf13/cobra v1.1.3 // indirect
github.com/spf13/cobra v1.3.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/twmb/go-rbtree v1.0.0 // indirect
go.uber.org/dig v1.13.0 // indirect
golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9 // indirect
golang.org/x/net v0.0.0-20220114011407-0dd24b26b47d // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678 // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect
google.golang.org/grpc v1.40.0 // indirect
google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5 // indirect
google.golang.org/grpc v1.43.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
Expand Down
Loading

0 comments on commit 1fda0a0

Please sign in to comment.