First part of changes to fall back to a read-only connection when a
read-write connection is not available. This refactors ClientStorage.notifyConnected() into two functions, testConnection() and notifyConnected(). testConnection creates the RPC stub and calls the register() method; it returns the stub plus a flag indicating whether this connection was preferred or sub-optimal. If the register() method raises ReadOnlyError, and the new option read_only_fallback was true on the ClientStorage constructor, it is retried with its read_only argument set to 1, and the stub is returned with the sub-optimal flag. notifyConnected() now receives the stub returned by testConnection(), and starts the verification as before. XXX The read_only_fallback feature is not yet tested. XXX More work is needed; when a suboptimal connection is used, the ConnectThread must stay around trying to get a preferred connection, and then it must switch connections on the ClientStorage (how???).
Showing
Please register or sign in to comment