2016-06-17 8 views
-1

私はNodeJs Appで作業しており、ロジック部分でオンラインWebサービスを呼び出す必要があります。Nodejs異なるAPIウェブサービスと対話するためのファサードパターン

問題は、そのWebサービスが停止すると、システム全体が機能しなくなることです。

これを処理するには、ファサードパターンを使用していますが、同じ機能を持つ別のWebサービスを追加します。同様の情報を持つオフラインファイルも1つだけ追加します。

考え方は、論理部品からファサード(javaScriptファイル?)を呼び出します。プライマリWebサービスを最初に選択して、それがダウンしている場合は2番目のWebサービスを呼び出し、ダウンしている場合はオフラインデータファイルを呼び出します。

これをNodeJSでどのように構築するかについてのご意見はありますか?

答えて

0

これは、可能な解決策

// Simple GET request example: 
 
$http({ 
 
    method: 'GET', 
 
    url: '/someUrl1' 
 
}).then(function (response) { 
 
    // this callback will be called asynchronously 
 
    // when the response is available 
 
    }, function (response) { 
 
    // called asynchronously if an error occurs 
 
    // or server returns response with an error status. 
 

 
    // In case it fails 
 
    $http({ 
 
     method: 'GET', 
 
     url: '/someUrl2' 
 
    }).then(function (response) { 
 
     // this callback will be called asynchronously 
 
     // when the response is available 
 
     }, function (response) { 
 
     // called asynchronously if an error occurs 
 
     // or server returns response with an error status. 
 
     
 
     // If it fails again, use JSON file here 
 
     }); 
 

 
    
 
    });

です
関連する問題