megastef / node-crate

Node.js base DB-Driver for CRATE (www.crate.io)
52 stars 18 forks source link

Support multiple crate hosts #2

Open martinheidegger opened 10 years ago

martinheidegger commented 10 years ago

The python client allows to specify multiple servers that are used as failsafe. Would be nice if the nodejs client supported that as well.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/3584096-support-multiple-crate-hosts?utm_campaign=plugin&utm_content=tracker%2F1042667&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1042667&utm_medium=issues&utm_source=github).
megastef commented 10 years ago

Ok, sounds good could also be used for load balancing - e.g. distribute requestst to multiple CRATE nodes - or fallback to another node when first fails. We faced also the situation that a single crate server was rejecting the connections (too many).

megastef commented 10 years ago

We do this in two steps. The first one is to support round robin when you specify multiple hosts. This one I just checked in (Vesion 1.0.3) We might add on option to specify strategy (e.g. fallback). It is more work as we need to detect connection errors and deal with it differntly. It would be shiny if we first try to queue failed requests, send them to other hosts and then callback the user defined success/error functions.