Skip to content

Commit

Permalink
remove unused AvroCodec
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianiacobghiula committed Jun 27, 2024
1 parent a65fddd commit bb3e3db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
IMAGE_NAME = pulsar-client-go-test:latest
PULSAR_VERSION ?= 3.2.2
PULSAR_IMAGE = apachepulsar/pulsar:$(PULSAR_VERSION)
GO_VERSION ?= 1.18
GO_VERSION ?= 1.20
CONTAINER_ARCH ?= $(shell uname -m | sed s/x86_64/amd64/)

# Golang standard bin directory.
Expand Down
29 changes: 7 additions & 22 deletions pulsar/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,10 @@ func NewSchema(schemaType SchemaType, schemaData []byte, properties map[string]s
return
}

type AvroCodec struct {
Codec avro.Schema
}

func NewSchemaDefinition(schema avro.Schema) *AvroCodec {
return &AvroCodec{
Codec: schema,
}
}

// initAvroCodec returns a Codec used to translate between a byte slice of either
// binary or textual Avro data and native Go data.
func initAvroCodec(codec string) (avro.Schema, error) {
return avro.Parse(codec)
func initAvroCodec(schemaDef string) (avro.Schema, error) {
return avro.Parse(schemaDef)
}

type JSONSchema struct {
Expand All @@ -162,8 +152,7 @@ func NewJSONSchemaWithValidation(jsonAvroSchemaDef string, properties map[string
if err != nil {
return nil, err
}
schemaDef := NewSchemaDefinition(avroCodec)
resolvedSchema, err := json.Marshal(schemaDef.Codec)
resolvedSchema, err := json.Marshal(avroCodec)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -191,7 +180,6 @@ func (js *JSONSchema) GetSchemaInfo() *SchemaInfo {
}

type ProtoSchema struct {
AvroCodec
SchemaInfo
}

Expand All @@ -214,12 +202,10 @@ func NewProtoSchemaWithValidation(protoAvroSchemaDef string, properties map[stri
if err != nil {
return nil, err
}
schemaDef := NewSchemaDefinition(avroCodec)
resolvedSchema, err := json.Marshal(schemaDef.Codec)
resolvedSchema, err := json.Marshal(avroCodec)
if err != nil {
return nil, err
}
ps.AvroCodec.Codec = schemaDef.Codec
ps.SchemaInfo.Schema = string(resolvedSchema)
ps.SchemaInfo.Type = PROTOBUF
ps.SchemaInfo.Properties = properties
Expand Down Expand Up @@ -322,7 +308,7 @@ func (ps *ProtoNativeSchema) GetSchemaInfo() *SchemaInfo {
}

type AvroSchema struct {
AvroCodec
Codec avro.Schema
SchemaInfo
}

Expand All @@ -343,9 +329,8 @@ func NewAvroSchemaWithValidation(avroSchemaDef string, properties map[string]str
if err != nil {
return nil, err
}
schemaDef := NewSchemaDefinition(avroCodec)
as.AvroCodec.Codec = schemaDef.Codec
resolvedSchema, err := json.Marshal(schemaDef.Codec)
as.Codec = avroCodec
resolvedSchema, err := json.Marshal(avroCodec)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit bb3e3db

Please sign in to comment.