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

Statebus file_store option should take a prefix rather than a boolean #39

Open
karth295 opened this issue Apr 7, 2018 · 4 comments
Open

Comments

@karth295
Copy link
Collaborator

karth295 commented Apr 7, 2018

E.g.

const bus = require('statebus').serve({file_store: {prefix: 'my_prefix'}})
$ diff server.js ~/statebus/server.js
9c9
<     file_store: {save_delay: 250, filename: 'db', backup_dir: 'backups', prefix: '*'},
---
>     file_store: {save_delay: 250, filename: 'db', backup_dir: 'backups'}, 
59c59
<             bus.file_store(bus.options.file_store.prefix)
---
>             bus.file_store('*')

I could also see an argument for an array:

const bus = require('statebus').serve({file_store: {prefixes: ['my_prefix_1', 'my_prefix_2']}})

Since this is a breaking change I'll let you deal with this.

@toomim
Copy link
Member

toomim commented Apr 7, 2018

  1. Adding prefix to the .serve() options is straightforward—I was just waiting for someone to want that feature.
  2. What do you mean by a boolean?
  3. Instead of an array of prefixes, we could also support regular expressions. Then you could do this with prefix: /my_prefix_1|my_prefix_2/. We could add this support to statebus as a whole. I've just been waiting for someone to need this feature.

@karth295
Copy link
Collaborator Author

karth295 commented Apr 7, 2018

Re number 2: right now file_store takes a boolean for whether all state should be stored or not. If you specify {file_store: false}, then try to do bus.file_store('some-prefix'), it throws an error (iirc).

+1 to a regex.

@toomim
Copy link
Member

toomim commented Apr 7, 2018

Ok, now you can do:

bus = require('statebus').serve({file_store: {prefix: 'savely'}})

Does this solve for you? It's committed and in npm. ac172b6

Here's the full list of options for file_store and their defaults:

    file_store: {save_delay: 250, filename: 'db', backup_dir: 'backups', prefix: '*'}

I guess this should go on the wiki.

@toomim
Copy link
Member

toomim commented Apr 7, 2018

Ok, I've added the server options to the wiki.

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

2 participants