奶头挺立呻吟高潮av全片,成人试看120秒体验区,性欧美极品v,A片高潮抽搐揉捏奶头视频

php語言

PHP構(gòu)建監(jiān)視服務(wù)的方法

時間:2024-06-19 19:15:10 php語言 我要投稿
  • 相關(guān)推薦

PHP構(gòu)建監(jiān)視服務(wù)的方法

  PHP監(jiān)視服務(wù)記錄程序應(yīng)該能夠支持任意的服務(wù)檢查(例如,HTTP和FTP服務(wù))并且能夠以任意方式(通過電子郵件,輸出到一個日志文件,等等)記錄事件。你當(dāng)然想讓它以一個守護(hù)程序方式運(yùn)行;所以,你應(yīng)該請求它輸出其完整的當(dāng)前狀態(tài)。以下是小編為大家搜索整理的PHP構(gòu)建監(jiān)視服務(wù)的方法,希望能給大家?guī)韼椭?更多精彩內(nèi)容請及時關(guān)注我們應(yīng)屆畢業(yè)生考試網(wǎng)!

  一個服務(wù)需要實(shí)現(xiàn)下列抽象類:

  abstract class ServiceCheck {

  const FAILURE = 0;

  const SUCCESS = 1;

  protected $timeout = 30;

  protected $next_attempt;

  protected $current_status = ServiceCheck::SUCCESS;

  protected $previous_status = ServiceCheck::SUCCESS;

  protected $frequency = 30;

  protected $description;

  protected $consecutive_failures = 0;

  protected $status_time;

  protected $failure_time;

  protected $loggers = array();

  abstract public function __construct($params);

  public function __call($name, $args)

  {

  if(isset($this->$name)) {

  return $this->$name;

  }

  }

  public function set_next_attempt()

  {

  $this->next_attempt = time() + $this->frequency;

  }

  public abstract function run();

  public function post_run($status)

  {

  if($status !== $this->current_status) {

  $this->previous_status = $this->current_status;

  }

  if($status === self::FAILURE) {

  if( $this->current_status === self::FAILURE ) {

  $this->consecutive_failures++;

  }

  else {

  $this->failure_time = time();

  }

  }

  else {

  $this->consecutive_failures = 0;

  }

  $this->status_time = time();

  $this->current_status = $status;

  $this->log_service_event();

  }

  public function log_current_status()

  {

  foreach($this->loggers as $logger) {

  $logger->log_current_status($this);

  }

  }

  private function log_service_event()

  {

  foreach($this->loggers as $logger) {

  $logger->log_service_event($this);

  }

  }

  public function register_logger(ServiceLogger $logger)

  {

  $this->loggers[] = $logger;

  }

  }

  上面的__call()重載方法提供對一個ServiceCheck對象的參數(shù)的只讀存取操作:

  · timeout-在引擎終止檢查之前,這一檢查能夠掛起多長時間。

  · next_attempt-下次嘗試連接到服務(wù)器的時間。

  · current_status-服務(wù)的當(dāng)前狀態(tài):SUCCESS或FAILURE。

  · previous_status-當(dāng)前狀態(tài)之前的狀態(tài)。

  · frequency-每隔多長時間檢查一次服務(wù)。

  · description-服務(wù)描述。

  · consecutive_failures-自從上次成功以來,服務(wù)檢查連續(xù)失敗的次數(shù)。

  · status_time-服務(wù)被檢查的最后時間。

  · failure_time-如果狀態(tài)為FAILED,則它代表發(fā)生失敗的時間。

  這個類還實(shí)現(xiàn)了觀察者模式,允許ServiceLogger類型的對象注冊自身,然后當(dāng)調(diào)用log_current_status()或log_service_event()時調(diào)用它。

  這里實(shí)現(xiàn)的關(guān)鍵函數(shù)是run(),它負(fù)責(zé)定義應(yīng)該怎樣執(zhí)行檢查。如果檢查成功,它應(yīng)該返回SUCCESS;否則返回FAILURE。

【PHP構(gòu)建監(jiān)視服務(wù)的方法】相關(guān)文章:

自學(xué)PHP方法09-24

PHP的安裝方法及軟件09-04

PHP偽靜態(tài)的方法10-26

解決php fsockopen的方法07-14

PHP入門構(gòu)建網(wǎng)站的步驟09-30

PHP常用MySql操作的方法10-11

PHP頁面漏洞分析的方法08-13

PHP環(huán)境搭建與配置的方法07-03

php創(chuàng)建cookie獲取方法10-28

php數(shù)組長度的方法10-05

主站蜘蛛池模板: 黔西县| 新余市| 尉氏县| 炎陵县| 甘肃省| 阿拉尔市| 宜昌市| 临城县| 章丘市| 宾阳县| 旺苍县| 定边县| 富宁县| 吴旗县| 波密县| 遂昌县| 鱼台县| 马关县| 沙洋县| 常州市| 余干县| 吉水县| 海安县| 高雄县| 镇安县| 渑池县| 遂昌县| 疏勒县| 凤冈县| 青岛市| 澎湖县| 通许县| 抚宁县| 黔西县| 阿城市| 大同县| 甘德县| 鹤山市| 宁安市| 安仁县| 北宁市|