Open
Description
Describe the problem and solution
문제가 되는 코드는 아래와 같습니다.
Redis자체에서(go-redis 라이브러리 포함) 오류가 생길 경우, 빈 TestCase를 받아오고 return해버려서, go-redis 오픈소스에서 문제가 생기면 채점 요청이 이뤄지지 못합니다. 이를 개선하기 위한 작업이 필요합니다.
++ 추가로, AWS ElastiCache에 문제가 생길 경우에 fallback로직도 마련할 필요가 있을것 같습니다.
func (t *testcaseManager) GetTestcase(problemId string) (Testcase, error) {
isExist, err := t.cache.IsExist(problemId)
if err != nil {
return Testcase{}, fmt.Errorf("GetTestcase: %w", err)
}
if !isExist {
bytes, err := t.source.Get(problemId)
if err != nil {
return Testcase{}, fmt.Errorf("get testcase: %w", err)
}
elements := []Element{}
err = json.Unmarshal(bytes, &elements) // validate
if err != nil {
return Testcase{}, fmt.Errorf("invalid testcase data: %w", err)
}
testcase := Testcase{Elements: elements}
err = t.cache.Set(problemId, testcase)
if err != nil {
return Testcase{}, fmt.Errorf("cache set: %w", err)
}
return testcase, nil
}
data, err := t.cache.Get(problemId)
if err != nil {
return Testcase{}, fmt.Errorf("testcase: %s: %w", problemId, err)
}
testcase := Testcase{}
err = testcase.UnmarshalBinary(data)
if err != nil {
return Testcase{}, fmt.Errorf("testcase: %w", err)
}
return testcase, nil
}
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines
- Check that there isn't already an issue
Metadata
Assignees
Type
Projects
Status
Pending ✋