From bb3e3db560d2140a03df30a43d89a5a9ae32a5c5 Mon Sep 17 00:00:00 2001 From: Adrian Iacob-Ghiula <2491756+adrianiacobghiula@users.noreply.github.com> Date: Thu, 27 Jun 2024 08:47:15 +0200 Subject: [PATCH] remove unused AvroCodec --- Makefile | 2 +- pulsar/schema.go | 29 +++++++---------------------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index ce41b206ee..fee46f6906 100644 --- a/Makefile +++ b/Makefile @@ -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. diff --git a/pulsar/schema.go b/pulsar/schema.go index 14a1f4b94f..bd8ba1d142 100644 --- a/pulsar/schema.go +++ b/pulsar/schema.go @@ -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 { @@ -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 } @@ -191,7 +180,6 @@ func (js *JSONSchema) GetSchemaInfo() *SchemaInfo { } type ProtoSchema struct { - AvroCodec SchemaInfo } @@ -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 @@ -322,7 +308,7 @@ func (ps *ProtoNativeSchema) GetSchemaInfo() *SchemaInfo { } type AvroSchema struct { - AvroCodec + Codec avro.Schema SchemaInfo } @@ -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 }