Skip to content

INTERNAL: Convert metadata between JSON and BSON - #15

Draft
ing-eoking wants to merge 1 commit into
nreadfrom
bson
Draft

ing-eoking wants to merge 1 commit into
nreadfrom
bson

Conversation

@ing-eoking

Copy link
Copy Markdown
Collaborator

🔗 Related Issue

  • #9의 후속 PR입니다. 다른 PR과 의존이 없어 develop에 바로 올립니다.

⌨️ What I did

메타데이터를 전송할 때는 JSON 객체로, 엔진에 저장할 때는 BSON 문서로 다룹니다. src/bson.rs가 둘 사이를 변환합니다.

  • bson crate(MongoDB 공식 구현)와 serde_json을 의존성에 추가했습니다.
    • serde_json의 preserve_order를 켜서 JSON → BSON → JSON을 거쳐도 키 순서가 그대로 유지됩니다.
  • from_json: JSON 객체를 BSON 문서로 바꿉니다.
    • 필드 값은 extended JSON으로 타입을 지정할 수 있습니다. 예를 들어 {"$numberLong":"5"}는 int64 5로 저장됩니다.
    • 최상위 키는 항상 필드 이름으로 읽습니다. {"$date":..,"a":..}도 날짜가 아닌 일반 객체로 처리합니다.
  • to_json: BSON 문서를 공백 없는 JSON으로 바꿉니다. relaxed extended JSON을 쓰므로 from_json으로 저장한 값은 일반 JSON으로 돌아옵니다. 소수점이 있는 double은 1.0처럼 소수부를 유지합니다.
  • 아직 이 모듈을 쓰는 명령이 없어 #[expect(dead_code)]로 표시했습니다.

에러

상황 응답
객체가 아닌 JSON, JSON 문법 오류, 깊이 32 이상 중첩, 키에 NUL, 잘못된 extended JSON 값 CLIENT_ERROR bad value
저장된 문서가 깨져서 JSON으로 바꿀 수 없음 SERVER_ERROR internal

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

This branch was successfully deployed

1 active (outdated) deployment
ee — b2af33ca Deployed Nov 2, 2026 by ing-eoking via Build arcus-memcached #63
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