summary refs log tree commit diff
path: root/synapse/config/_base.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-10-20 17:52:25 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2020-10-20 17:52:25 +0100
commit581445c6290a4482c920f9d8a0113867acf1bd6f (patch)
tree20d09f7cafb9cb71f52897512590818d6ff85500 /synapse/config/_base.py
parentMerge commit 'be16ee59a' into anoa/dinsic_release_1_21_x (diff)
parentRevert "Add experimental support for sharding event persister. (#8170)" (#8242) (diff)
downloadsynapse-581445c6290a4482c920f9d8a0113867acf1bd6f.tar.xz
Merge commit '9f8abdcc3' into anoa/dinsic_release_1_21_x
* commit '9f8abdcc3':
  Revert "Add experimental support for sharding event persister. (#8170)" (#8242)
Diffstat (limited to 'synapse/config/_base.py')
-rw-r--r--synapse/config/_base.py21
1 files changed, 3 insertions, 18 deletions
diff --git a/synapse/config/_base.py b/synapse/config/_base.py

index 876bd354ab..1477b27326 100644 --- a/synapse/config/_base.py +++ b/synapse/config/_base.py
@@ -833,26 +833,11 @@ class ShardedWorkerHandlingConfig: def should_handle(self, instance_name: str, key: str) -> bool: """Whether this instance is responsible for handling the given key. """ - # If multiple instances are not defined we always return true + + # If multiple instances are not defined we always return true. if not self.instances or len(self.instances) == 1: return True - return self.get_instance(key) == instance_name - - def get_instance(self, key: str) -> str: - """Get the instance responsible for handling the given key. - - Note: For things like federation sending the config for which instance - is sending is known only to the sender instance if there is only one. - Therefore `should_handle` should be used where possible. - """ - - if not self.instances: - return "master" - - if len(self.instances) == 1: - return self.instances[0] - # We shard by taking the hash, modulo it by the number of instances and # then checking whether this instance matches the instance at that # index. @@ -862,7 +847,7 @@ class ShardedWorkerHandlingConfig: dest_hash = sha256(key.encode("utf8")).digest() dest_int = int.from_bytes(dest_hash, byteorder="little") remainder = dest_int % (len(self.instances)) - return self.instances[remainder] + return self.instances[remainder] == instance_name __all__ = ["Config", "RootConfig", "ShardedWorkerHandlingConfig"]