gawamango 是我用在 Cursor
帮助下实现的本地 MongoDB 代理服务器。
开发这个只是想更直观学习 MongoDB 的 Wire Protocol 是什么样子的。
其使用也是非常简单(根据 v0.3.6 的版本):
1
2
3
4
| go install github.com/ringsaturn/gawamango/cmd/gawamango@latest
# 本地运行
OTEL_TRACES_EXPORTER=stdout gawamango -listen localhost:27018 -target localhost:27017
|
然后就能直接调用代理服务器的端口了:
1
2
3
4
5
| from pymongo import MongoClient
client = MongoClient("mongodb://localhost:27018/")
client.foo.bar.insert_one({"name": "John"})
|
这个项目还非常简单,如果后面我的时间和精力允许,并且还对 MongoDB 的协议、BSON
结构感兴趣,我可能会继续完善这个项目。 争取在不使用 MongoDB
官方的任何库的情况下,实现一个可以正常工作的 MongoDB 代理服务器。