1 <?php
2 /**
3 * Copyright 2012-2014 Rackspace US, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 namespace OpenCloud\LoadBalancer\Resource;
19
20 /**
21 * Active health monitoring is a technique that uses synthetic transactions
22 * executed at periodic intervals to determine the condition of a node. One of
23 * the advantages of active health monitoring is that it does not require active
24 * transactions to be processed by the load balancer to determine whether or not
25 * a node is suitable for handling traffic. Active health monitoring is not
26 * applied by default and must be enabled per load balancer.
27 *
28 * The active health monitor can use one of three types of probes:
29 *
30 * * connect
31 * * HTTP
32 * * HTTPS
33 *
34 * These probes are executed at configured intervals; in the event of a failure,
35 * the node status changes to OFFLINE and the node will not receive traffic. If,
36 * after running a subsequent test, the probe detects that the node has recovered,
37 * then the node's status is changed to ONLINE and it is capable of servicing requests.
38 */
39 class HealthMonitor extends NonIdUriResource
40 {
41 /**
42 * Type of the health monitor. Can either be "connect", "HTTP" or "HTTPS"
43 *
44 * @var string
45 */
46 public $type;
47
48 /**
49 * The minimum number of seconds to wait before executing the health monitor.
50 * Must be a number between 1 and 3600.
51 *
52 * @var int
53 */
54 public $delay;
55
56 /**
57 * Maximum number of seconds to wait for a connection to be established
58 * before timing out. Must be a number between 1 and 300.
59 *
60 * @var int
61 */
62 public $timeout;
63
64 /**
65 * Number of permissible monitor failures before removing a node from rotation.
66 * Must be a number between 1 and 10.
67 *
68 * @var int
69 */
70 public $attemptsBeforeDeactivation;
71
72 /**
73 * A regular expression that will be used to evaluate the contents of the
74 * body of the response.
75 *
76 * @var string
77 */
78 public $bodyRegex;
79
80 /**
81 * The name of a host for which the health monitors will check.
82 *
83 * @var string
84 */
85 public $hostHeader;
86
87 /**
88 * The HTTP path that will be used in the sample request.
89 *
90 * @var string
91 */
92 public $path;
93
94 /**
95 * A regular expression that will be used to evaluate the HTTP status code
96 * returned in the response.
97 *
98 * @var string
99 */
100 public $statusRegex;
101
102 protected static $json_name = 'healthMonitor';
103 protected static $url_resource = 'healthmonitor';
104
105 protected $createKeys = array(
106 'type',
107 'delay',
108 'timeout',
109 'attemptsBeforeDeactivation',
110 'bodyRegex',
111 'hostHeader',
112 'path',
113 'statusRegex'
114 );
115
116 public function create($params = array())
117 {
118 return $this->update($params);
119 }
120 }
121