Skip to content

Conversation

@hyeonjae
Copy link

@hyeonjae hyeonjae commented Jun 9, 2021

If the record has avro type, the codec is not recognized.

{
  "type": "record",
  "name": "Parent",                  
  "fields" : [
    {"name": "child", "type": "Child"}
  ]
}

To solve this problem, I suggest the following constructor modifier

parent := `
{
  "type": "record",
  "name": "Parent",                  
  "fields" : [
    {"name": "child", "type": "Child"}
  ]
}
`

modifier := func(st map[string]*Codec) {
	st["Child"] = childCodec
}

codec, err := NewCodec(parent, modifier)

As NewCodec function prototype is like below, doesn't hurt compatibility.

func NewCodec(schemaSpecification string, modifiers ...CodecModifier) (*Codec, error) 

@xmcqueen
Copy link
Contributor

xmcqueen commented Sep 29, 2021

@hyeonjae Can you provide a fail case so I can understand the problem a little more? I was toying with making that a variadic and adding a codec just the other day for a different purpose. It would be ideal to get a test case that fails. I'll look into this a bit more now that I see you've already provided some test cases. Thanks

@xmcqueen
Copy link
Contributor

xmcqueen commented Oct 6, 2021

I like this idea. I'll wait a bit for folks to comment.

@survivorbat
Copy link

I like this idea too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants