Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
stewartboyd119 committed Sep 23, 2024
1 parent 4bc4a79 commit f25b0ca
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 19 deletions.
12 changes: 9 additions & 3 deletions example/producer_avro/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ func main() {
Formatter: zkafka.AvroSchemaRegistry,
SchemaRegistry: zkafka.SchemaRegistryConfig{
URL: "http://localhost:8081",
Serialization: struct{ AutoRegisterSchemas bool }{
Serialization: zkafka.SerializationConfig{
// This likely isn't needed in production. A typical workflow involves registering
// a schema a priori. But for the local example, to save this setup, the flag is set to true
AutoRegisterSchemas: true,
// When using avro schema registry, you must specify the schema. In this case,
// the schema used to generate the golang type is used.
// The heetch generated struct also embeds the schema as well (and isn't lossy like some of the
// other generative solutions. For example, one lib didn't include default values), so that could be used as well.
Schema: dummyEventSchema,
},
},
})
Expand All @@ -38,8 +45,7 @@ func main() {
StringField: randomNames[rand.Intn(len(randomNames))],
}

resp, err := writer.Write(ctx, event, zkafka.WithAvroSchema(dummyEventSchema))
//resp, err := writer.Write(ctx, &event)
resp, err := writer.Write(ctx, event)
if err != nil {
log.Panic(err)
}
Expand Down
18 changes: 17 additions & 1 deletion example/worker_avro/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,33 @@ replace github.com/zillow/zkafka v1.0.0 => ../..

require (
github.com/google/uuid v1.6.0
github.com/heetch/avro v0.4.5
github.com/zillow/zkafka v1.0.0
)

require (
github.com/actgardner/gogen-avro/v10 v10.2.1 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/bufbuild/protocompile v0.8.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/confluentinc/confluent-kafka-go/v2 v2.5.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/heetch/avro v0.4.5 // indirect
github.com/hamba/avro/v2 v2.20.1 // indirect
github.com/invopop/jsonschema v0.12.0 // indirect
github.com/jhump/protoreflect v1.15.6 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.3.0 // indirect
github.com/sony/gobreaker v1.0.0 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/zillow/zfmt v1.0.1 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
golang.org/x/sync v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20240325203815-454cdb8f5daa // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit f25b0ca

Please sign in to comment.