diff --git a/protocol.go b/protocol.go index fdc9b8ed..28608eb8 100644 --- a/protocol.go +++ b/protocol.go @@ -49,8 +49,6 @@ type Protocol struct { doc string hash string - - originalString string } // NewProtocol creates a protocol instance. @@ -58,7 +56,6 @@ func NewProtocol( name, namepsace string, types []NamedSchema, messages map[string]*Message, - protocolString string, opts ...ProtocolOption, ) (*Protocol, error) { var cfg protocolConfig @@ -72,12 +69,11 @@ func NewProtocol( } p := &Protocol{ - name: n, - properties: newProperties(cfg.props, protocolReserved), - types: types, - messages: messages, - doc: cfg.doc, - originalString: protocolString, + name: n, + properties: newProperties(cfg.props, protocolReserved), + types: types, + messages: messages, + doc: cfg.doc, } b := md5.Sum([]byte(p.String())) @@ -106,11 +102,6 @@ func (p *Protocol) Types() []NamedSchema { return p.types } -// OriginalString returns the original string of the protocol. -func (p *Protocol) OriginalString() string { - return p.originalString -} - // String returns the canonical form of the protocol. func (p *Protocol) String() string { types := "" @@ -240,7 +231,7 @@ func ParseProtocol(protocol string) (*Protocol, error) { } seen := seenCache{} - return parseProtocol(m, seen, cache, protocol) + return parseProtocol(m, seen, cache) } type protocol struct { @@ -252,7 +243,7 @@ type protocol struct { Props map[string]any `mapstructure:",remain"` } -func parseProtocol(m map[string]any, seen seenCache, cache *SchemaCache, protocolString string) (*Protocol, error) { +func parseProtocol(m map[string]any, seen seenCache, cache *SchemaCache) (*Protocol, error) { var ( p protocol meta mapstructure.Metadata @@ -288,7 +279,7 @@ func parseProtocol(m map[string]any, seen seenCache, cache *SchemaCache, protoco } } - return NewProtocol(p.Protocol, p.Namespace, types, messages, protocolString, WithProtoDoc(p.Doc), WithProtoProps(p.Props)) + return NewProtocol(p.Protocol, p.Namespace, types, messages, WithProtoDoc(p.Doc), WithProtoProps(p.Props)) } func parseProtocolTypes(namespace string, types []any, seen seenCache, cache *SchemaCache) ([]NamedSchema, error) { diff --git a/protocol_test.go b/protocol_test.go index c919311a..4eb2b970 100644 --- a/protocol_test.go +++ b/protocol_test.go @@ -21,20 +21,11 @@ func TestMustParseProtocol_PanicsOnError(t *testing.T) { } func TestNewProtocol_ValidatesName(t *testing.T) { - _, err := avro.NewProtocol("0test", "", nil, nil, "") + _, err := avro.NewProtocol("0test", "", nil, nil) assert.Error(t, err) } -func TestNewProtocol_OriginalString(t *testing.T) { - schema := `{"protocol":"test", "namespace": "org.hamba.avro", "messages":{"test":{"request": [{"name": "foobar", "type": "string"}]}}}` - - proto, err := avro.ParseProtocol(schema) - - assert.NoError(t, err) - assert.Equal(t, schema, proto.OriginalString()) -} - func TestNewMessage(t *testing.T) { field, _ := avro.NewField("test", avro.NewPrimitiveSchema(avro.String, nil)) fields := []*avro.Field{field}