Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

중첩 스키마 인식을 위한 코덱 생성자 수정 #1

Merged
merged 5 commits into from
Jun 11, 2021

Conversation

hyeonjae
Copy link

아래와 같이 레코드 내에 Child라는 다른 커스텀 레코드 타입이 있는 경우, 인식하지 못해요.

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

이를 위해 아래와같이, Codec 생성시 참조할 다른 코덱을 주입할 수 있게 생성자를 수정했어요.

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

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

codec, err := NewCodec(parent, modifier)

NewCodec 생성자에 variadic argument로 인자를 추가하여, 기존 호환성을 해치지 않게 하였어요.

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

@hyeonjae hyeonjae requested a review from taeuk June 10, 2021 06:35
@hyeonjae
Copy link
Author

일단 머지할게요~

@hyeonjae hyeonjae merged commit ff0bc2c into daangn:master Jun 11, 2021
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.

1 participant