Mercurial > hg > orthanc-stone
comparison Platforms/Generic/OracleWebService.h @ 309:14ef1227120f am-callable-and-promise
web services: better handling of failures
author | am@osimis.io |
---|---|
date | Fri, 28 Sep 2018 15:02:43 +0200 |
parents | 547e1cf7aa7b |
children | aad37d0b6407 |
comparison
equal
deleted
inserted
replaced
307:be2660b6e40a | 309:14ef1227120f |
---|---|
11 * | 11 * |
12 * This program is distributed in the hope that it will be useful, but | 12 * This program is distributed in the hope that it will be useful, but |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | 15 * Affero General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Affero General Public License | 17 * You should have received a copy of the GNU Affero General Public License |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | 19 **/ |
20 | 20 |
21 | 21 |
53 | 53 |
54 virtual void GetAsync(const std::string& uri, | 54 virtual void GetAsync(const std::string& uri, |
55 const Headers& headers, | 55 const Headers& headers, |
56 Orthanc::IDynamicObject* payload, // takes ownership | 56 Orthanc::IDynamicObject* payload, // takes ownership |
57 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, // takes ownership | 57 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, // takes ownership |
58 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL)// takes ownership | 58 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL,// takes ownership |
59 unsigned int timeoutInSeconds = 60) | |
59 { | 60 { |
60 oracle_.Submit(new WebServiceGetCommand(broker_, successCallback, failureCallback, parameters_, uri, headers, payload, context_)); | 61 oracle_.Submit(new WebServiceGetCommand(broker_, successCallback, failureCallback, parameters_, uri, headers, timeoutInSeconds, payload, context_)); |
61 } | 62 } |
62 | 63 |
63 virtual void PostAsync(const std::string& uri, | 64 virtual void PostAsync(const std::string& uri, |
64 const Headers& headers, | 65 const Headers& headers, |
65 const std::string& body, | 66 const std::string& body, |
66 Orthanc::IDynamicObject* payload, // takes ownership | 67 Orthanc::IDynamicObject* payload, // takes ownership |
67 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, // takes ownership | 68 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback, // takes ownership |
68 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback) // takes ownership | 69 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback = NULL, // takes ownership |
70 unsigned int timeoutInSeconds = 60) | |
69 { | 71 { |
70 oracle_.Submit(new WebServicePostCommand(broker_, successCallback, failureCallback, parameters_, uri, headers, body, payload, context_)); | 72 oracle_.Submit(new WebServicePostCommand(broker_, successCallback, failureCallback, parameters_, uri, headers, timeoutInSeconds, body, payload, context_)); |
71 } | 73 } |
72 | 74 |
73 void Start() | 75 void Start() |
74 { | 76 { |
75 oracle_.Start(); | 77 oracle_.Start(); |
76 } | 78 } |
77 | 79 |
78 void Stop() | 80 void Stop() |
79 { | 81 { |
80 oracle_.Stop(); | 82 oracle_.Stop(); |
81 } | 83 } |
82 }; | 84 }; |
83 } | 85 } |