Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementazione della logica di retry per Guzzle HTTP Client #39

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static function get_href($html){

private function find_betting_files_url(){
\App\Http\Controllers\Admin\ActionLogController::log(0,"adm_system","trying to find betting adm blacklist links");
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try {
$response = $client->get(env("ADM_BETTING_URL"));
}catch(\GuzzleHttp\Exception\BadResponseException $e){
Expand Down Expand Up @@ -157,7 +157,7 @@ private function parse_betting_file($save){

private function find_smoking_files_url(){
\App\Http\Controllers\Admin\ActionLogController::log(0,"adm_system","trying to find smoking adm blacklist links");
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try {
$response = $client->get(env("ADM_SMOKING_URL"));
}catch(\GuzzleHttp\Exception\BadResponseException $e){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ private static function new_login(){
$body_request = new \StdClass();
$body_request->email = env("PIRACY_SHIELD_MAIL");
$body_request->password = env("PIRACY_SHIELD_PSW");
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->post($endpoint,["json" => $body_request,'connect_timeout' => 5]);
if($response->getBody()){
Expand Down Expand Up @@ -745,7 +745,7 @@ private static function refresh_login($token){
$endpoint = self::buildUrl("/api/v1/authentication/refresh");
$body_request = new \StdClass();
$body_request->refresh_token = $token;
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->post($endpoint,["json" => $body_request,'connect_timeout' => 5]);
if($response->getBody()){
Expand Down Expand Up @@ -798,7 +798,7 @@ private static function logout(){
$endpoint = self::buildUrl("/api/v1/authentication/logout");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['headers' => ['Authorization' => "Bearer $access_token"],'connect_timeout' => 5]);
if($response->getBody()){
Expand Down Expand Up @@ -851,7 +851,7 @@ private static function get_ticket($ticket_id,$is_retry = false){
$endpoint = self::buildUrl("/api/v1/ticket/get");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->ticket_id = $ticket_id;
try{
Expand Down Expand Up @@ -920,7 +920,7 @@ private static function get_all_tickets($is_retry = false){
$endpoint = self::buildUrl("/api/v1/ticket/get/all");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['headers' => ['Authorization' => "Bearer $access_token", 'Accept-Encoding' => 'gzip'], 'connect_timeout' => 60, 'decode_content' => 'gzip']);
if($response->getBody()){
Expand Down Expand Up @@ -991,7 +991,7 @@ private static function get_fqdns_from_ticket($ticket_id,$is_retry = false){
$endpoint = self::buildUrl("/api/v1/ticket/get/fqdn");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->ticket_id = $ticket_id;
try{
Expand Down Expand Up @@ -1060,7 +1060,7 @@ private static function get_ipv4s_from_ticket($ticket_id,$is_retry = false){
$endpoint = self::buildUrl("/api/v1/ticket/get/ipv4");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->ticket_id = $ticket_id;
try{
Expand Down Expand Up @@ -1129,7 +1129,7 @@ private static function get_ipv6s_from_ticket($ticket_id,$is_retry = false){
$endpoint = self::buildUrl("/api/v1/ticket/get/ipv6");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->ticket_id = $ticket_id;
try{
Expand Down Expand Up @@ -1198,7 +1198,7 @@ private static function get_all_fqdns_json($is_retry = false){
$endpoint = self::buildUrl("/api/v1/fqdn/get/all");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['headers' => ['Authorization' => "Bearer $access_token"],'connect_timeout' => 10]);
if($response->getBody()){
Expand Down Expand Up @@ -1269,7 +1269,7 @@ private static function get_all_ipv4s_json($is_retry = false){
$endpoint = self::buildUrl("/api/v1/ipv4/get/all");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['headers' => ['Authorization' => "Bearer $access_token"],'connect_timeout' => 10]);
if($response->getBody()){
Expand Down Expand Up @@ -1340,7 +1340,7 @@ private static function get_all_ipv6s_json($is_retry = false){
$endpoint = self::buildUrl("/api/v1/ipv6/get/all");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['headers' => ['Authorization' => "Bearer $access_token"],'connect_timeout' => 10]);
if($response->getBody()){
Expand Down Expand Up @@ -1411,7 +1411,7 @@ private static function set_item_processed($ticket_item,$is_retry = false){
$endpoint = self::buildUrl("/api/v1/ticket/item/set/processed");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->value = $ticket_item;
try{
Expand Down Expand Up @@ -1480,7 +1480,7 @@ private static function set_item_unprocessed($ticket_item,$reason,$is_retry = fa
$endpoint = self::buildUrl("/api/v1/ticket/item/set/unprocessed");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->value = $ticket_item;
$body_request->reason = $reason;
Expand Down Expand Up @@ -1550,7 +1550,7 @@ private static function get_whitelist($is_retry = false){
$endpoint = self::buildUrl("/api/v1/whitelist/item/get/all");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['headers' => ['Authorization' => "Bearer $access_token"],'connect_timeout' => 5]);
if($response->getBody()){
Expand Down Expand Up @@ -1621,7 +1621,7 @@ private static function delete_whitelist($genre,$item,$is_retry = false){
$endpoint = self::buildUrl("/api/v1/whitelist/item/remove");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->item = $item;
try{
Expand Down Expand Up @@ -1690,7 +1690,7 @@ private static function add_whitelist($genre,$item,$attr_name,$attr,$is_retry =
$endpoint = self::buildUrl("/api/v1/whitelist/item/create");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->genre = $genre;
$body_request->item = $item;
Expand Down Expand Up @@ -1759,7 +1759,7 @@ private static function add_whitelist($genre,$item,$attr_name,$attr,$is_retry =
public static function ping(){
\App\Http\Controllers\Admin\ActionLogController::log(0,"piracy_system","trying to ping system");
$endpoint = self::buildUrl("/api/v1/ping");
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['connect_timeout' => 5]);
if($response->getBody()){
Expand Down
6 changes: 3 additions & 3 deletions ps.openaccessitalia.org-main/app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ protected function schedule(Schedule $schedule)
//UPDATE ADM BLACKLISTS
$schedule->call('App\Http\Controllers\ADMController@update_blacklists')->timezone('Europe/Rome')->dailyAt('9:00');
//UPDATE PIRACY SHIELD
$schedule->call('App\Http\Controllers\PiracyController@run')->timezone('Europe/Rome')->everyTenMinutes();
$schedule->call('App\Http\Controllers\PiracyController@run')->timezone('Europe/Rome')->everyFiveMinutes();
//UPDATE DNS
$schedule->call('App\Http\Controllers\Admin\AdminController@update_dns')->timezone('Europe/Rome')->everyTenMinutes();
$schedule->call('App\Http\Controllers\Admin\AdminController@update_dns')->timezone('Europe/Rome')->everyFiveMinutes();
//UPDATE BGP
$schedule->call('App\Http\Controllers\Admin\AdminController@update_bgp')->timezone('Europe/Rome')->everyTenMinutes();
$schedule->call('App\Http\Controllers\Admin\AdminController@update_bgp')->timezone('Europe/Rome')->everyFiveMinutes();
//LOG RETENTION
$schedule->call('App\Http\Controllers\Admin\AdminController@log_retention')->timezone('Europe/Rome')->hourly();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static function get_href($html){

private function find_betting_files_url(){
\App\Http\Controllers\Admin\ActionLogController::log(0,"adm_system","trying to find betting adm blacklist links");
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try {
$response = $client->get(env("ADM_BETTING_URL"));
}catch(\GuzzleHttp\Exception\BadResponseException $e){
Expand Down Expand Up @@ -157,7 +157,7 @@ private function parse_betting_file($save){

private function find_smoking_files_url(){
\App\Http\Controllers\Admin\ActionLogController::log(0,"adm_system","trying to find smoking adm blacklist links");
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try {
$response = $client->get(env("ADM_SMOKING_URL"));
}catch(\GuzzleHttp\Exception\BadResponseException $e){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ private static function new_login(){
$body_request = new \StdClass();
$body_request->email = env("PIRACY_SHIELD_MAIL");
$body_request->password = env("PIRACY_SHIELD_PSW");
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->post($endpoint,["json" => $body_request,'connect_timeout' => 5]);
if($response->getBody()){
Expand Down Expand Up @@ -745,7 +745,7 @@ private static function refresh_login($token){
$endpoint = self::buildUrl("/api/v1/authentication/refresh");
$body_request = new \StdClass();
$body_request->refresh_token = $token;
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->post($endpoint,["json" => $body_request,'connect_timeout' => 5]);
if($response->getBody()){
Expand Down Expand Up @@ -798,7 +798,7 @@ private static function logout(){
$endpoint = self::buildUrl("/api/v1/authentication/logout");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['headers' => ['Authorization' => "Bearer $access_token"],'connect_timeout' => 5]);
if($response->getBody()){
Expand Down Expand Up @@ -851,7 +851,7 @@ private static function get_ticket($ticket_id,$is_retry = false){
$endpoint = self::buildUrl("/api/v1/ticket/get");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->ticket_id = $ticket_id;
try{
Expand Down Expand Up @@ -920,7 +920,7 @@ private static function get_all_tickets($is_retry = false){
$endpoint = self::buildUrl("/api/v1/ticket/get/all");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['headers' => ['Authorization' => "Bearer $access_token", 'Accept-Encoding' => 'gzip'], 'connect_timeout' => 60, 'decode_content' => 'gzip']);
if($response->getBody()){
Expand Down Expand Up @@ -991,7 +991,7 @@ private static function get_fqdns_from_ticket($ticket_id,$is_retry = false){
$endpoint = self::buildUrl("/api/v1/ticket/get/fqdn");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->ticket_id = $ticket_id;
try{
Expand Down Expand Up @@ -1060,7 +1060,7 @@ private static function get_ipv4s_from_ticket($ticket_id,$is_retry = false){
$endpoint = self::buildUrl("/api/v1/ticket/get/ipv4");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->ticket_id = $ticket_id;
try{
Expand Down Expand Up @@ -1129,7 +1129,7 @@ private static function get_ipv6s_from_ticket($ticket_id,$is_retry = false){
$endpoint = self::buildUrl("/api/v1/ticket/get/ipv6");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->ticket_id = $ticket_id;
try{
Expand Down Expand Up @@ -1198,7 +1198,7 @@ private static function get_all_fqdns_json($is_retry = false){
$endpoint = self::buildUrl("/api/v1/fqdn/get/all");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['headers' => ['Authorization' => "Bearer $access_token"],'connect_timeout' => 10]);
if($response->getBody()){
Expand Down Expand Up @@ -1269,7 +1269,7 @@ private static function get_all_ipv4s_json($is_retry = false){
$endpoint = self::buildUrl("/api/v1/ipv4/get/all");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['headers' => ['Authorization' => "Bearer $access_token"],'connect_timeout' => 10]);
if($response->getBody()){
Expand Down Expand Up @@ -1340,7 +1340,7 @@ private static function get_all_ipv6s_json($is_retry = false){
$endpoint = self::buildUrl("/api/v1/ipv6/get/all");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['headers' => ['Authorization' => "Bearer $access_token"],'connect_timeout' => 10]);
if($response->getBody()){
Expand Down Expand Up @@ -1411,7 +1411,7 @@ private static function set_item_processed($ticket_item,$is_retry = false){
$endpoint = self::buildUrl("/api/v1/ticket/item/set/processed");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->value = $ticket_item;
try{
Expand Down Expand Up @@ -1480,7 +1480,7 @@ private static function set_item_unprocessed($ticket_item,$reason,$is_retry = fa
$endpoint = self::buildUrl("/api/v1/ticket/item/set/unprocessed");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->value = $ticket_item;
$body_request->reason = $reason;
Expand Down Expand Up @@ -1550,7 +1550,7 @@ private static function get_whitelist($is_retry = false){
$endpoint = self::buildUrl("/api/v1/whitelist/item/get/all");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['headers' => ['Authorization' => "Bearer $access_token"],'connect_timeout' => 5]);
if($response->getBody()){
Expand Down Expand Up @@ -1621,7 +1621,7 @@ private static function delete_whitelist($genre,$item,$is_retry = false){
$endpoint = self::buildUrl("/api/v1/whitelist/item/remove");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->item = $item;
try{
Expand Down Expand Up @@ -1690,7 +1690,7 @@ private static function add_whitelist($genre,$item,$attr_name,$attr,$is_retry =
$endpoint = self::buildUrl("/api/v1/whitelist/item/create");
$access_token = self::get_access_token(false);
if($access_token){
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
$body_request = new \StdClass();
$body_request->genre = $genre;
$body_request->item = $item;
Expand Down Expand Up @@ -1759,7 +1759,7 @@ private static function add_whitelist($genre,$item,$attr_name,$attr,$is_retry =
public static function ping(){
\App\Http\Controllers\Admin\ActionLogController::log(0,"piracy_system","trying to ping system");
$endpoint = self::buildUrl("/api/v1/ping");
$client = new \GuzzleHttp\Client();
$client = new \App\Http\HttpClient();
try{
$response = $client->get($endpoint,['connect_timeout' => 5]);
if($response->getBody()){
Expand Down
Loading