Skip to content
Snippets Groups Projects
Unverified Commit d1158bb8 authored by Eelco Dolstra's avatar Eelco Dolstra
Browse files

Cache connection failures

parent 8490ee37
No related branches found
No related tags found
No related merge requests found
......@@ -44,13 +44,26 @@ RemoteStore::RemoteStore(const Params & params)
: Store(params)
, connections(make_ref<Pool<Connection>>(
std::max(1, std::stoi(get(params, "max-connections", "1"))),
[this]() { return openConnection(); },
[this]() { return openConnectionWrapper(); },
[](const ref<Connection> & r) { return r->to.good() && r->from.good(); }
))
{
}
ref<RemoteStore::Connection> RemoteStore::openConnectionWrapper()
{
if (failed)
throw Error("opening a connection to remote store ‘%s’ previously failed", getUri());
try {
return openConnection();
} catch (...) {
failed = true;
throw;
}
}
UDSRemoteStore::UDSRemoteStore(const Params & params)
: Store(params)
, LocalFSStore(params)
......
......@@ -98,6 +98,8 @@ protected:
void processStderr(Sink * sink = 0, Source * source = 0);
};
ref<Connection> openConnectionWrapper();
virtual ref<Connection> openConnection() = 0;
void initConnection(Connection & conn);
......@@ -106,6 +108,8 @@ protected:
private:
std::atomic_bool failed{false};
void setOptions(Connection & conn);
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment