@@ 714-740 (lines=27) @@ | ||
711 | * @param array $options extra options for backend |
|
712 | * @return string |
|
713 | */ |
|
714 | protected function _vcl_director_backend($host, $port, $descriptor = '', $probeUrl = '', $options = array()) { |
|
715 | $tpl = <<<EOS |
|
716 | { |
|
717 | .backend {$descriptor} = { |
|
718 | .host = "{{host}}"; |
|
719 | .port = "{{port}}"; |
|
720 | {{probe}} |
|
721 | ||
722 | EOS; |
|
723 | $vars = array( |
|
724 | 'host' => $host, |
|
725 | 'port' => $port, |
|
726 | 'probe' => '' |
|
727 | ); |
|
728 | if ( ! empty($probeUrl)) { |
|
729 | $vars['probe'] = $this->_vcl_get_probe($probeUrl); |
|
730 | } |
|
731 | $str = $this->_formatTemplate($tpl, $vars); |
|
732 | foreach ($options as $key => $value) { |
|
733 | $str .= sprintf(' .%s = %s;', $key, $value).PHP_EOL; |
|
734 | } |
|
735 | $str .= <<<EOS |
|
736 | } |
|
737 | } |
|
738 | EOS; |
|
739 | return $str; |
|
740 | } |
|
741 | ||
742 | /** |
|
743 | * Format a VCL probe declaration to put in backend which is in director |
@@ 179-204 (lines=26) @@ | ||
176 | * @param array $options extra options for backend |
|
177 | * @return string |
|
178 | */ |
|
179 | protected function _vcl_director_backend($host, $port, $descriptor = '', $probeUrl = '', $options = array()) { |
|
180 | $tpl = <<<EOS |
|
181 | backend web{$descriptor} { |
|
182 | .host = "{{host}}"; |
|
183 | .port = "{{port}}"; |
|
184 | {{probe}} |
|
185 | ||
186 | EOS; |
|
187 | $vars = array( |
|
188 | 'host' => $host, |
|
189 | 'port' => $port, |
|
190 | 'probe' => '' |
|
191 | ); |
|
192 | if ( ! empty($probeUrl)) { |
|
193 | $vars['probe'] = $this->_vcl_get_probe($probeUrl); |
|
194 | } |
|
195 | $str = $this->_formatTemplate($tpl, $vars); |
|
196 | foreach ($options as $key => $value) { |
|
197 | $str .= sprintf(' .%s = %s;', $key, $value).PHP_EOL; |
|
198 | } |
|
199 | $str .= <<<EOS |
|
200 | } |
|
201 | ||
202 | EOS; |
|
203 | return $str; |
|
204 | } |
|
205 | } |
|
206 |