Closed msimerson closed 7 years ago
I agree with all of this except for creating it as a separate repository. This code should be in core IMO.
And I think it goes without saying that connection.notes.foo = 'bar';
etc. must continue to work as they do now. We just make it preferable to do it via get/set and then for v3 we mandate get/set only.
If it's only in core, then all the advantages of having smarter notes aren't available in the test suite without duplicating the set/get code into haraka-test-fixtures. And then keeping it in sync in the future when we extend notes further. That's less than idea.
I'm envisioning the implementation of notes.js as being not greatly more complicated than:
const Notes = {};
module.exports = Notes;
Notes.prototype.get(path) {
// code
}
Notes.prototype.set(path, value) {
// code
}
There's no reason it wouldn't continue to work just fine with legacy usage.
Ok - yeah, I forgot that haraka-test-fixtures was separate now to handle testing of the plugins as modules.
Background: over the years we've seen many dozens of crashing bugs related to attempts to set or access object properties that don't exist. This has led to a lot of defensive code whereby plugins write code like this:
Much of this was mitigated with haraka-results as it provided standard locations for various types of data as well as setters and getters. We should do the same for notes, implemented such that a pleasant and easy syntax such as this works:
TODO
.get()
and.set()
propertiesStretch Goals