mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Refactor RPCSub to remove Application dependency
This commit is contained in:
@@ -631,7 +631,8 @@ public:
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Must run as directed or exit.
|
||||
WriteLog (lsFATAL, Application) << boost::str (boost::format ("Can not open RPC service: %s") % e.what ());
|
||||
WriteLog (lsFATAL, Application) <<
|
||||
"Can not open RPC service: " << e.what ();
|
||||
|
||||
exit (3);
|
||||
}
|
||||
|
||||
@@ -3233,7 +3233,8 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, LoadType* loadType, App
|
||||
{
|
||||
WriteLog (lsDEBUG, RPCHandler) << boost::str (boost::format ("doSubscribe: building: %s") % strUrl);
|
||||
|
||||
RPCSub::pointer rspSub = boost::make_shared<RPCSub> (strUrl, strUsername, strPassword);
|
||||
RPCSub::pointer rspSub = boost::make_shared<RPCSub> (getApp ().getIOService (),
|
||||
getApp ().getJobQueue (), strUrl, strUsername, strPassword);
|
||||
ispSub = mNetOps->addRpcSub (strUrl, boost::dynamic_pointer_cast<InfoSub> (rspSub));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -6,8 +6,15 @@
|
||||
|
||||
SETUP_LOG (RPCSub)
|
||||
|
||||
RPCSub::RPCSub (const std::string& strUrl, const std::string& strUsername, const std::string& strPassword)
|
||||
: mUrl (strUrl), mSSL (false), mUsername (strUsername), mPassword (strPassword), mSending (false)
|
||||
RPCSub::RPCSub (boost::asio::io_service& io_service, JobQueue& jobQueue,
|
||||
const std::string& strUrl, const std::string& strUsername, const std::string& strPassword)
|
||||
: m_io_service (io_service)
|
||||
, m_jobQueue (jobQueue)
|
||||
, mUrl (strUrl)
|
||||
, mSSL (false)
|
||||
, mUsername (strUsername)
|
||||
, mPassword (strPassword)
|
||||
, mSending (false)
|
||||
{
|
||||
std::string strScheme;
|
||||
|
||||
@@ -75,7 +82,7 @@ void RPCSub::sendThread ()
|
||||
WriteLog (lsINFO, RPCSub) << boost::str (boost::format ("callRPC calling: %s") % mIp);
|
||||
|
||||
callRPC (
|
||||
getApp().getIOService (),
|
||||
m_io_service,
|
||||
mIp, mPort,
|
||||
mUsername, mPassword,
|
||||
mPath, "event",
|
||||
@@ -113,7 +120,7 @@ void RPCSub::send (const Json::Value& jvObj, bool broadcast)
|
||||
|
||||
WriteLog (lsINFO, RPCSub) << boost::str (boost::format ("callRPC start"));
|
||||
|
||||
getApp().getJobQueue ().addJob (
|
||||
m_jobQueue.addJob (
|
||||
jtCLIENT, "RPCSub::sendThread", BIND_TYPE (&RPCSub::sendThread, this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ public:
|
||||
typedef boost::shared_ptr<RPCSub> pointer;
|
||||
typedef const pointer& ref;
|
||||
|
||||
RPCSub (const std::string& strUrl, const std::string& strUsername, const std::string& strPassword);
|
||||
RPCSub (boost::asio::io_service& io_service,
|
||||
JobQueue& jobQueue, const std::string& strUrl,
|
||||
const std::string& strUsername, const std::string& strPassword);
|
||||
|
||||
virtual ~RPCSub ()
|
||||
{
|
||||
@@ -46,6 +48,9 @@ protected:
|
||||
void sendThread ();
|
||||
|
||||
private:
|
||||
boost::asio::io_service& m_io_service;
|
||||
JobQueue& m_jobQueue;
|
||||
|
||||
std::string mUrl;
|
||||
std::string mIp;
|
||||
int mPort;
|
||||
|
||||
Reference in New Issue
Block a user