| @@ 162-187 (lines=26) @@ | ||
| 159 | * @param array $options extra options for backend |
|
| 160 | * @return string |
|
| 161 | */ |
|
| 162 | protected function _vcl_director_backend($host, $port, $descriptor, $probeUrl = '', $options = array()) { |
|
| 163 | $tpl = <<<EOS |
|
| 164 | backend web{$descriptor} { |
|
| 165 | .host = "{{host}}"; |
|
| 166 | .port = "{{port}}"; |
|
| 167 | {{probe}} |
|
| 168 | ||
| 169 | EOS; |
|
| 170 | $vars = array( |
|
| 171 | 'host' => $host, |
|
| 172 | 'port' => $port, |
|
| 173 | 'probe' => '' |
|
| 174 | ); |
|
| 175 | if ( ! empty($probeUrl)) { |
|
| 176 | $vars['probe'] = $this->_vcl_get_probe($probeUrl); |
|
| 177 | } |
|
| 178 | $str = $this->_formatTemplate($tpl, $vars); |
|
| 179 | foreach ($options as $key => $value) { |
|
| 180 | $str .= sprintf(' .%s = %s;', $key, $value).PHP_EOL; |
|
| 181 | } |
|
| 182 | $str .= <<<EOS |
|
| 183 | } |
|
| 184 | ||
| 185 | EOS; |
|
| 186 | return $str; |
|
| 187 | } |
|
| 188 | } |
|
| 189 | ||
| @@ 686-712 (lines=27) @@ | ||
| 683 | * @param array $options extra options for backend |
|
| 684 | * @return string |
|
| 685 | */ |
|
| 686 | protected function _vcl_director_backend($host, $port, $probeUrl = '', $options = array()) { |
|
| 687 | $tpl = <<<EOS |
|
| 688 | { |
|
| 689 | .backend = { |
|
| 690 | .host = "{{host}}"; |
|
| 691 | .port = "{{port}}"; |
|
| 692 | {{probe}} |
|
| 693 | ||
| 694 | EOS; |
|
| 695 | $vars = array( |
|
| 696 | 'host' => $host, |
|
| 697 | 'port' => $port, |
|
| 698 | 'probe' => '' |
|
| 699 | ); |
|
| 700 | if ( ! empty($probeUrl)) { |
|
| 701 | $vars['probe'] = $this->_vcl_get_probe($probeUrl); |
|
| 702 | } |
|
| 703 | $str = $this->_formatTemplate($tpl, $vars); |
|
| 704 | foreach ($options as $key => $value) { |
|
| 705 | $str .= sprintf(' .%s = %s;', $key, $value).PHP_EOL; |
|
| 706 | } |
|
| 707 | $str .= <<<EOS |
|
| 708 | } |
|
| 709 | } |
|
| 710 | EOS; |
|
| 711 | return $str; |
|
| 712 | } |
|
| 713 | ||
| 714 | /** |
|
| 715 | * Format a VCL probe declaration to put in backend which is in director |
|