Jamie Hannaford | 21a3eb1 | 2014-11-03 10:34:29 +0100 | [diff] [blame] | 1 | package nodes |
| 2 | |
Jamie Hannaford | 940cece | 2014-11-03 10:59:36 +0100 | [diff] [blame^] | 3 | // Node represents a back-end device, usually a virtual machine, that can |
| 4 | // handle traffic. It is assigned traffic based on its parent load balancer. |
Jamie Hannaford | 21a3eb1 | 2014-11-03 10:34:29 +0100 | [diff] [blame] | 5 | type Node struct { |
Jamie Hannaford | 940cece | 2014-11-03 10:59:36 +0100 | [diff] [blame^] | 6 | // The IP address or CIDR for this back-end node. |
| 7 | Address string |
| 8 | |
| 9 | // The unique ID for this node. |
| 10 | ID int |
| 11 | |
| 12 | // The port on which traffic is sent and received. |
| 13 | Port int |
| 14 | |
| 15 | // The node's status. |
| 16 | Status Status |
| 17 | |
| 18 | // The node's condition. |
Jamie Hannaford | 21a3eb1 | 2014-11-03 10:34:29 +0100 | [diff] [blame] | 19 | Condition string |
Jamie Hannaford | 940cece | 2014-11-03 10:59:36 +0100 | [diff] [blame^] | 20 | |
| 21 | // The priority at which this node will receive traffic if a weighted |
| 22 | // algorithm is used by its parent load balancer. Ranges from 1 to 100. |
| 23 | Weight int |
| 24 | |
| 25 | // Type of node. |
| 26 | Type Type |
Jamie Hannaford | 21a3eb1 | 2014-11-03 10:34:29 +0100 | [diff] [blame] | 27 | } |
Jamie Hannaford | 940cece | 2014-11-03 10:59:36 +0100 | [diff] [blame^] | 28 | |
| 29 | // Type indicates whether the node is of a PRIMARY or SECONDARY nature. |
| 30 | type Type string |
| 31 | |
| 32 | const ( |
| 33 | // PRIMARY nodes are in the normal rotation to receive traffic from the load |
| 34 | // balancer. |
| 35 | PRIMARY Type = "PRIMARY" |
| 36 | |
| 37 | // SECONDARY nodes are only in the rotation to receive traffic from the load |
| 38 | // balancer when all the primary nodes fail. This provides a failover feature |
| 39 | // that automatically routes traffic to the secondary node in the event that |
| 40 | // the primary node is disabled or in a failing state. Note that active |
| 41 | // health monitoring must be enabled on the load balancer to enable the |
| 42 | // failover feature to the secondary node. |
| 43 | SECONDARY Type = "SECONDARY" |
| 44 | ) |
| 45 | |
| 46 | type Condition string |
| 47 | |
| 48 | const ( |
| 49 | // ENABLED indicates that the node is permitted to accept new connections. |
| 50 | ENABLED Condition = "ENABLED" |
| 51 | |
| 52 | // DISABLED indicates that the node is not permitted to accept any new |
| 53 | // connections regardless of session persistence configuration. Existing |
| 54 | // connections are forcibly terminated. |
| 55 | DISABLED Condition = "DISABLED" |
| 56 | |
| 57 | // DRAINING indicates that the node is allowed to service existing |
| 58 | // established connections and connections that are being directed to it as a |
| 59 | // result of the session persistence configuration. |
| 60 | DRAINING |
| 61 | ) |
| 62 | |
| 63 | // Status indicates whether the node can accept service traffic. If a node is |
| 64 | // not listening on its port or does not meet the conditions of the defined |
| 65 | // active health check for the load balancer, then the load balancer does not |
| 66 | // forward connections and its status is listed as OFFLINE |
| 67 | type Status string |
| 68 | |
| 69 | const ( |
| 70 | // ONLINE indicates that the node is healthy and capable of receiving traffic |
| 71 | // from the load balancer. |
| 72 | ONLINE Status = "ONLINE" |
| 73 | |
| 74 | // OFFLINE indicates that the node is not in a position to receive service |
| 75 | // traffic. It is usually switched into this state when a health check is not |
| 76 | // satisfied with the node's response time. |
| 77 | OFFLINE Status = "OFFLINE" |
| 78 | ) |