pub enum ResponsePolicy {
OneSucceeded,
AllSucceeded,
AggLogicalAnd,
AggLogicalOr,
AggMin,
AggMax,
AggSum,
Special,
}
Expand description
This tip can help clients determine the aggregate they need to compute from the replies of multiple shards in a cluster.
The default behavior for commands without a request_policy tip only applies to replies with of nested types (i.e., an array, a set, or a map). The client’s implementation for the default behavior should be as follows:
- The command doesn’t accept key name arguments: the client can aggregate all replies within a single nested data structure.
For example, the array replies we get from calling
keys
against all shards. These should be packed in a single in no particular order. - For commands that accept one or more key name arguments: the client needs to retain the same order of replies as the input key names.
For example,
mget
’s aggregated reply.
Variants§
OneSucceeded
the clients should return success if at least one shard didn’t reply with an error.
The client should reply with the first non-error reply it obtains.
If all shards return an error, the client can reply with any one of these.
For example, consider a script_kill
command that’s sent to all shards.
Although the script should be loaded in all of the cluster’s shards,
the script_kill
will typically run only on one at a given time.
AllSucceeded
the client should return successfully only if there are no error replies.
Even a single error reply should disqualify the aggregate and be returned.
Otherwise, the client should return one of the non-error replies.
As an example, consider the config_set
,
script_flush
and
script_load
commands.
AggLogicalAnd
the client should return the result of a logical AND
operation on all replies
(only applies to integer replies, usually from commands that return either 0 or 1).
Consider the script_exists
command as an example.
It returns an array of 0’s and 1’s that denote the existence of its given SHA1 sums in the script cache.
The aggregated response should be 1 only when all shards had reported that a given script SHA1 sum is in their respective cache.
AggLogicalOr
the client should return the result of a logical OR
operation on all replies
(only applies to integer replies, usually from commands that return either 0 or 1).
AggMin
the client should return the minimal value from the replies (only applies to numerical replies).
The aggregate reply from a cluster-wide wait
command, for example,
should be the minimal value (number of synchronized replicas) from all shards
AggMax
the client should return the maximal value from the replies (only applies to numerical replies).
AggSum
the client should return the sum of replies (only applies to numerical replies).
Example: dbsize
.
Special
this type of tip indicates a non-trivial form of reply policy.
info
is an excellent example of that.
Trait Implementations§
Source§impl Clone for ResponsePolicy
impl Clone for ResponsePolicy
Source§fn clone(&self) -> ResponsePolicy
fn clone(&self) -> ResponsePolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more