Skip to content

Commit

Permalink
feat(fxgcppubsub): Fixed race conditions on avro binary codec
Browse files Browse the repository at this point in the history
  • Loading branch information
ekkinox committed Jul 9, 2024
1 parent 90066ff commit 76f6495
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fxgcppubsub/codec/avro.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ var (

// AvroBinaryCodec is a Codec implementation for encoding and decoding with avro schema in binary format.
type AvroBinaryCodec struct {
cache *avro.SchemaCache
api avro.API
schema avro.Schema
}

// NewAvroBinaryCodec returns a new AvroBinaryCodec instance.
func NewAvroBinaryCodec(schemaDefinition string) (*AvroBinaryCodec, error) {
cache := &avro.SchemaCache{}

api := avro.Config{}.Freeze()

schema, err := avro.Parse(schemaDefinition)
schema, err := avro.ParseBytesWithCache([]byte(schemaDefinition), "", cache)
if err != nil {
return nil, fmt.Errorf("cannot parse avro schema: %w", err)
}
Expand Down

0 comments on commit 76f6495

Please sign in to comment.