Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Store, NewStore, Open, and Session #97

Open
pascallouisperez opened this issue Apr 9, 2018 · 0 comments
Open

Cleanup Store, NewStore, Open, and Session #97

pascallouisperez opened this issue Apr 9, 2018 · 0 comments

Comments

@pascallouisperez
Copy link
Contributor

Right now, the Session is the concrete object which provides "database storage" functionality. We even document it in the code

// Assert Session implements Store interface.
var _ Store = &Session{}

One suggestion would be to get rid of the DbStore struct, remove NewStore, and instead have

func Open(defs *Definitions, tx *runner.Tx) (*Session, error) {

which would combine what NewStore > Open do right now. We may even want to rename Session to DbSession for clarity, or renamed Open to CreateDbSession.

One drawback of this API, is that we may want to add a way to verify that the database is well formed (e.g. all tables are present, all indexes are created with proper name), which this somewhat limits. An approach would be to add CheckDb(conn) error and let callers invoke this upon startup (if they so choose).

Of note, what we have now is no better, because when DbStore is created, we are not given a connection to the database, so would be impossible to do any validation.

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

No branches or pull requests

1 participant