Server(url, oauth, basic) => Server(env)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Microfiber |
Fix Released
|
High
|
Jason Gerard DeRose |
Bug Description
The tricky thing about desktopcouch is that things like the port and oauth tokens are different each session. And the trickier thing about the Novacut components is that they need to run against both desktopcouch and system wide CouchDB without knowing the difference.
I've spent a lot of time trying to find the right abstractions to allow this to work nicely. First I tried API abstractions, but after much thought, I think the correct abstraction is a simple, extensible data structure, the `env` dictionary I've been using all over the place.
The idea is that this `env` can describe both the system-wide CouchDB environment and the desktopcouch environment, and is extensible so we can add things we haven't thought of yet. Importantly, we want to be able add things to the `env` and have all the intermediary code still just blindly pass around this single `env` variable. Only two places need to know the details, the entry point that starts the process, and where the rubber meets the CouchDB road: Microfiber!
For example, the `env` for system-wide CouchDB looks like this:
{
"url": "http://
}
And the `env` for desktopcouch/dc3 would look something like this:
{
"basic": {
"password": "5GF2HP7SRPVB6HY2",
"username": "QOZ525Z5RXP7AO4C"
},
"oauth": {
"token": "6745HGQJLNHUQG2E",
},
"url": "http://
}
So I think Microfiber should use the same extensible convention. Currently Microfiber supports oauth and basic auth (with keyword arguments for each), but what if we need to add support for oauth2? So I'm proposing we change the __init__() signatures from:
Server(url, oauth, basic)
Database(name, url, oauth, basic)
To:
Server(env)
Database(name, env)
That way the code in, say, dmedia, can just blindly pass microfiber the env and be completely hidden from the details. This is a good abstraction and will reduce the code and complexity needed in the middle.
Related branches
- David Jordan: Approve
-
Diff: 448 lines (+118/-97)3 files modifiedbenchmark_microfiber.py (+23/-1)
microfiber.py (+30/-17)
test_microfiber.py (+65/-79)
Changed in microfiber: | |
status: | In Progress → Fix Committed |
Changed in microfiber: | |
status: | Fix Committed → Fix Released |