-
Notifications
You must be signed in to change notification settings - Fork 1.5k
suggestion: Simpler API with constructor-style Open #41
Comments
Similarly, if Bucket was a datatype that's actually useful for callers, and refcounted the buckets, one could use that to avoid the error on every call of .Cursor; the only source for error is bucket not existing. |
I like the idea of adding
I'm hesitant to defer Ultimately I think most people will use the Thanks for taking such a deep dive into the code and poking around. It's great to get feedback like this! |
I wrote that part before discovering Do() and With(). They look good, hopefully the closures won't cost too much. |
@tv42 I'm a little worried about closure performance too but hopefully it won't be too bad. I'll add some closure vs non-closure benchmarks once I get to profiling. |
@tv42 I'm going to move the data accessor and mutator functions from
If accessors (e.g. I'm still going to keep those functions on I'll try to get to it this weekend but it may be early next week before I can do it. |
Added |
db: return t.Rollback directly in the end of View function
Mirroring os.File, if instead of DB.Open you had
func Open(name string, mode os.FileMode) (*DB, error)
that could save some error checking, and even more interestingly, that would almost remove the current only source of errors for DB.Transaction and .RWTransaction.
Almost because one could still run db.Close(); d.Transaction(). But that oughta be rare enough... so to make this idea complete, what if .Transaction and .RWTransaction, when run on a closed db, always successfully returned transactions, where all the operations will just fail? So in essence, this would delay the error checking to the point where you need to check errors anyway. This seems well aligned with http://talks.golang.org/2013/bestpractices.slide#5 and would, in my opinion, simplify typical code.
Unless you foresee other sources of errors for Transaction and RWTransaction.
P.S. Bolt looks really promising. No more fighting with cgo for me!
The text was updated successfully, but these errors were encountered: