mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-14 06:06:40 +00:00
create a StorageClientConfig object
Make it easier to pass more storage configuration down into StorageFarmBroker and beyond
This commit is contained in:
parent
6e3cd2d91c
commit
b5a2c70a4a
@ -536,8 +536,9 @@ def create_storage_farm_broker(config, default_connection_handlers, foolscap_con
|
||||
:param list introducer_clients: IntroducerClient instances if
|
||||
we're connecting to any
|
||||
"""
|
||||
ps = config.get_config("client", "peers.preferred", "").split(",")
|
||||
preferred_peers = tuple([p.strip() for p in ps if p != ""])
|
||||
storage_client_config = storage_client.StorageClientConfig.from_node_config(
|
||||
config,
|
||||
)
|
||||
|
||||
def tub_creator(handler_overrides=None, **kwargs):
|
||||
return node.create_tub(
|
||||
@ -551,7 +552,7 @@ def create_storage_farm_broker(config, default_connection_handlers, foolscap_con
|
||||
sb = storage_client.StorageFarmBroker(
|
||||
permute_peers=True,
|
||||
tub_maker=tub_creator,
|
||||
preferred_peers=preferred_peers,
|
||||
storage_client_config=storage_client_config,
|
||||
)
|
||||
for ic in introducer_clients:
|
||||
sb.use_introducer(ic)
|
||||
|
@ -69,7 +69,17 @@ from allmydata.util.hashutil import permute_server_hash
|
||||
# look like?
|
||||
# don't pass signatures: only pass validated blessed-objects
|
||||
|
||||
@attr.s
|
||||
class StorageClientConfig(object):
|
||||
preferred_peers = attr.ib(default=())
|
||||
@classmethod
|
||||
def from_node_config(cls, config):
|
||||
ps = config.get_config("client", "peers.preferred", "").split(",")
|
||||
preferred_peers = tuple([p.strip() for p in ps if p != ""])
|
||||
|
||||
return cls(
|
||||
preferred_peers,
|
||||
)
|
||||
@implementer(IStorageBroker)
|
||||
class StorageFarmBroker(service.MultiService):
|
||||
"""I live on the client, and know about storage servers. For each server
|
||||
@ -78,12 +88,25 @@ class StorageFarmBroker(service.MultiService):
|
||||
I'm also responsible for subscribing to the IntroducerClient to find out
|
||||
about new servers as they are announced by the Introducer.
|
||||
"""
|
||||
def __init__(self, permute_peers, tub_maker, preferred_peers=()):
|
||||
|
||||
@property
|
||||
def preferred_peers(self):
|
||||
return self.storage_client_config.preferred_peers
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
permute_peers,
|
||||
tub_maker,
|
||||
storage_client_config=None,
|
||||
):
|
||||
service.MultiService.__init__(self)
|
||||
assert permute_peers # False not implemented yet
|
||||
self.permute_peers = permute_peers
|
||||
self._tub_maker = tub_maker
|
||||
self.preferred_peers = preferred_peers
|
||||
|
||||
if storage_client_config is None:
|
||||
storage_client_config = StorageClientConfig()
|
||||
self.storage_client_config = storage_client_config
|
||||
|
||||
# self.servers maps serverid -> IServer, and keeps track of all the
|
||||
# storage servers that we've heard about. Each descriptor manages its
|
||||
|
Loading…
x
Reference in New Issue
Block a user