bwgjoseph / mongoose-vs-ottoman

feature comparison between mongoose and ottoman
0 stars 1 forks source link

better dx around indexes #103

Open bwgjoseph opened 3 years ago

bwgjoseph commented 3 years ago

Based on the issue around #90, and #97, the common problem here is that the developer has no control over when the indexes are ready, and if it's not, the startup would throw an error.

This issue is to consolidate all other issues pertaining/relating to this to keep the issue list clean.

An extract of my comment in https://github.com/bwgjoseph/mongoose-vs-ottoman/issues/90#issuecomment-868328940

My only feedback here is that to provide a better developer experience around this either by throwing a better error or to provide some options to wait until all indexes are ready before starting the server/service. If the developer wants to let the index build on the background while allowing the server/service to still start first, then any query before the index(es) is build, should just fallback to the primary index? where the query still works but slower because not using index. I'm not sure if this is feasible though, just a thought.

AV25242 commented 2 years ago

We released Ottoman beta.9 today please verify

We have added watchIndexes, basically gives you ability to assign a callback where you can find when the indexes are built.

bwgjoseph commented 2 years ago

Is watchIndexes something for developer to call? I can't seem to find the docs for it, is it available already?

gsi-alejandro commented 2 years ago

hi @bwgjoseph

in beta.9 we add an experimental layer for watchIndexes on Ottoman, but it will be ready in the new beta.10 released today or maybe tomorrow (September, 28th)

image documentation preview picture:

watchIndexes from SDK will be handle like the Ottoman's event 'IndexOnline', like describe in the picture above

bwgjoseph commented 2 years ago

I'm confused about start now that there's watchIndexes. Doesn't start also wait for indexes to be created?

Reading back the previous comments, it seem that it does not. In that case, would that means that I always require to wait for IndexOnline event to happen before accepting traffic?

gsi-alejandro commented 2 years ago

We are still working on it, but we implement it separately because the key-value operations will not require indexes. e.g. save, update, replace, findById

It's just a proposal, is very possible to change in the future, maybe the start function includes it activate by an option flag. I will notify you about any change in this API.

bwgjoseph commented 2 years ago

Sure. I think allowing us to set the flag make sense if I want to defer it to let start waits for the indexes to be ready rather than listening to the event myself. But having the event also allows me to have more flexibility if I need it.

AV25242 commented 2 years ago

This should be available with GA release please check it out @bwgjoseph

bwgjoseph commented 2 years ago

Is it the one with the ottoman.on('IndexOnline') event or with the option flag to the start method?