问题
I finally have written a retry policy for Cassandra in nodejs, I have a use case where the whenever there is a one node replica available I need to allow the read and write by modifying my consistency to the minimum level.
I have attached my updated retry code (DowngradeRetryPolicy in retry.js), Could you please check the link and give your comments,
https://gist.github.com/harigist/f74b29976702a84f8f37e1bf7b509e0e
1) I expect the list of problems in using this retry policy?
2) Anything wrong with this code? Is there a change I need to make to handle corner cases?
回答1:
Using a downgrading consistency retry policy causes your application consistency guarantee to be at minimum level. It would be theoretically equivalent to use a lower consistency level the first time.
I personally don't see much use for that type of policy except in the cases when you are handling a "normal mode" and "degraded mode" of your application.
About the code, it looks good to me.
回答2:
Question... as per the docs the policy interface consists of four methods:
onReadTimeout
, onUnavailable
, onWriteTimeout
, and onRequestError
in your policy, i only see 3. If any are omitted, what happens? Is the default logic used?
Also, another thing I see you're not using in your code is a _childPolicy
https://github.com/datastax/nodejs-driver/blob/master/lib/policies/retry.js#L160
来源:https://stackoverflow.com/questions/48202044/retry-policies-in-cassandra-using-nodejs