mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-07 19:04:21 +00:00
Add tub_handlers arg to NativeStorageServer constructor
Here we also define tub_handlers as a node attribute and pass it all the way down to the NativeStorageServer via the Client and StorageFarmBroker
This commit is contained in:
parent
85cf1d65be
commit
61eb839843
@ -370,7 +370,8 @@ class Client(node.Node, pollmixin.PollMixin):
|
||||
preferred_peers = tuple([p.strip() for p in ps if p != ""])
|
||||
sb = storage_client.StorageFarmBroker(permute_peers=True,
|
||||
preferred_peers=preferred_peers,
|
||||
tub_options=self.tub_options)
|
||||
tub_options=self.tub_options,
|
||||
tub_handlers=self.tub_handlers)
|
||||
self.storage_broker = sb
|
||||
sb.setServiceParent(self)
|
||||
|
||||
|
@ -203,6 +203,7 @@ class Node(service.MultiService):
|
||||
def create_tub(self):
|
||||
certfile = os.path.join(self.basedir, "private", self.CERTFILE)
|
||||
self.tub = Tub(certFile=certfile)
|
||||
self.tub_handlers = {}
|
||||
self.tub_options = {
|
||||
"logLocalFailures": True,
|
||||
"logRemoteFailures": True,
|
||||
|
@ -67,12 +67,13 @@ 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, preferred_peers=(), tub_options={}):
|
||||
def __init__(self, permute_peers, preferred_peers=(), tub_options={}, tub_handlers={}):
|
||||
service.MultiService.__init__(self)
|
||||
assert permute_peers # False not implemented yet
|
||||
self.permute_peers = permute_peers
|
||||
self.preferred_peers = preferred_peers
|
||||
self._tub_options = tub_options
|
||||
self._tub_handlers = tub_handlers
|
||||
|
||||
# self.servers maps serverid -> IServer, and keeps track of all the
|
||||
# storage servers that we've heard about. Each descriptor manages its
|
||||
@ -131,7 +132,7 @@ class StorageFarmBroker(service.MultiService):
|
||||
precondition(isinstance(key_s, str), key_s)
|
||||
precondition(key_s.startswith("v0-"), key_s)
|
||||
assert ann["service-name"] == "storage"
|
||||
s = NativeStorageServer(key_s, ann, self._tub_options)
|
||||
s = NativeStorageServer(key_s, ann, self._tub_options, self._tub_handlers)
|
||||
s.on_status_changed(lambda _: self._got_connection())
|
||||
serverid = s.get_serverid()
|
||||
old = self.servers.get(serverid)
|
||||
@ -243,11 +244,12 @@ class NativeStorageServer(service.MultiService):
|
||||
"application-version": "unknown: no get_version()",
|
||||
}
|
||||
|
||||
def __init__(self, key_s, ann, tub_options={}):
|
||||
def __init__(self, key_s, ann, tub_options={}, tub_handlers={}):
|
||||
service.MultiService.__init__(self)
|
||||
self.key_s = key_s
|
||||
self.announcement = ann
|
||||
self._tub_options = tub_options
|
||||
self._tub_handlers = tub_handlers
|
||||
|
||||
assert "anonymous-storage-FURL" in ann, ann
|
||||
furl = str(ann["anonymous-storage-FURL"])
|
||||
@ -348,8 +350,8 @@ class NativeStorageServer(service.MultiService):
|
||||
self._tub = Tub()
|
||||
for (name, value) in self._tub_options.items():
|
||||
self._tub.setOption(name, value)
|
||||
# XXX todo: do stuff with the handlers
|
||||
self._tub.setServiceParent(self)
|
||||
|
||||
furl = str(self.announcement["anonymous-storage-FURL"])
|
||||
self._trigger_cb = trigger_cb
|
||||
self._reconnector = self._tub.connectTo(furl, self._got_connection)
|
||||
|
Loading…
x
Reference in New Issue
Block a user