| Home | Trees | Indices | Help |
|
|---|
|
|
twisted.application.service.Service --+
|
twisted.application.service.MultiService --+
|
Tub
I am a presence in the PB universe, also known as a Tub.
I am a Service (in the twisted.application.service.Service sense), so you either need to call my startService() method before using me, or setServiceParent() me to a running service.
This is the primary entry point for all PB-using applications, both clients and servers.
I am known to the outside world by a base URL, which may include authentication information (a yURL). This is my 'TubID'.
I contain Referenceables, and manage RemoteReferences to Referenceables that live in other Tubs.
|
|||
|
negotiationClass This is the first protocol to speak over the wire. |
|||
|
brokerClass I manage a connection to a remote Broker. |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
| string |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from |
|||
|
|||
unsafeTracebacks = True
|
|||
logLocalFailures = False
|
|||
logRemoteFailures = False
|
|||
debugBanana = False
|
|||
NAMEBITS = 160
|
|||
TUBIDBITS = 16
|
|||
encrypted = True
|
|||
keepaliveTimeout = 240
|
|||
disconnectTimeout = None
|
|||
__implemented__ = <implementedBy foolscap.pb.Tub>
|
|||
__provides__ = <zope.interface.declarations.ClassProvides obje
|
|||
|
Inherited from |
|||
|
|||
| string |
tubID = Nonea global identifier for this Tub, possibly including authentication information, hash of SSL certificate |
||
|
brokers maps TubIDs to Broker instances |
|||
|
listeners maps strport to TCPServer service |
|||
|
nameToReference maps name to Referenceable |
|||
|
referenceToName maps Referenceable to a name |
|||
|
|||
|
Tell this service what its location is: a host:port description of how
to reach it from the outside world. You need to use this because the Tub
can't do it without help. If you do a
s.setLocation('foo.example.com:1234')
You must set the location before you can register any references. Encrypted Tubs can have multiple location hints, just provide multiple arguments. Unauthenticated Tubs can only have one location. |
Determine one of this host's publically-visible IP addresses and use it to set our location. This uses whatever source address would be used to get to a well-known public host (A.ROOT-SERVERS.NET), which is effectively the interface on which a default route lives. This is neither very pretty (IP address instead of hostname) nor guaranteed to work (it may very well be a 192.168 'private' address), but for publically-visible hosts this will probably produce a useable FURL. This method returns a Deferred that will fire once the location is actually established. Calls to registerReference() must be put off until the location has been set. And of course, you must call listenOn() before calling autoSetLocation(). |
Start listening for connections.
|
|
|
Make a Referenceable available to the outside world. A URL is returned which can be used to access this object. This registration will remain in effect (and the Tub will retain a reference to the object to keep it meaningful) until explicitly unregistered, or the Tub is shut down.
|
Make a Referenceable available to the outside world, but do not retain a strong reference to it. If we must create a new name, use preferred_name. If that is None, use a random unguessable name. |
Add a function to help convert names to Referenceables. When remote systems pass a FURL to their Tub.getReference(), our Tub will be asked to locate a Referenceable for the name inside that furl. The normal mechanism for this is to look at the table maintained by registerReference() and unregisterReference(). If the name does not exist in that table, other 'lookup handler' functions are given a chance. Each lookup handler is asked in turn, and the first which returns a non-None value wins. This may be useful for cases where the furl represents an object that lives on disk, or is generated on demand: rather than creating all possible Referenceables at startup, the lookup handler can create or retrieve the objects only when someone asks for them. Note that constructing the FURLs of these objects may be non-trivial. It is safe to create an object, use tub.registerReference in one invocation of a program to obtain (and publish) the furl, parse the furl to extract the name, save the contents of the object on disk, then in a later invocation of the program use a lookup handler to retrieve the object from disk. This approach means the objects that are created in a given invocation stick around (inside tub.strongReferences) for the rest of that invocation. An alternatve approach is to create the object but *not* use tub.registerReference, but in that case you have to construct the FURL yourself, and the Tub does not currently provide any support for doing this robustly.
|
Acquire a RemoteReference for the given SturdyRef/URL. The Tub must be running (i.e. Tub.startService()) when this is invoked. Future releases may relax this requirement.
|
Establish (and maintain) a connection to a given PBURL. I establish a connection to the PBURL and run a callback to inform the caller about the newly-available RemoteReference. If the connection is lost, I schedule a reconnection attempt for the near future. If that one fails, I keep trying at longer and longer intervals (exponential backoff). I accept a callback which will be fired each time a connection attempt succeeds. This callback is run with the new RemoteReference and any additional args/kwargs provided to me. The callback should then use rref.notifyOnDisconnect() to get a message when the connection goes away. At some point after it goes away, the Reconnector will reconnect. The Tub must be running (i.e. Tub.startService()) when this is invoked. Future releases may relax this requirement. I return a Reconnector object. When you no longer want to maintain this connection, call the stopConnecting() method on the Reconnector. I promise to not invoke your callback after you've called stopConnecting(), even if there was already a connection attempt in progress. If you had an active connection before calling stopConnecting(), you will still have access to it, until it breaks on its own. (I will not attempt to break existing connections, I will merely stop trying to create new ones). All my Reconnector objects will be shut down when the Tub is stopped. Usage:
def _got_ref(rref, arg1, arg2):
rref.callRemote('hello again')
# etc
rc = tub.connectTo(_got_ref, 'arg1', 'arg2')
...
rc.stopConnecting() # later
|
|
|||
__provides__
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Tue Oct 14 18:27:48 2008 | http://epydoc.sourceforge.net |