blob: d32fa771d936a17f18e2821632014c3273614ab2 [file] [log] [blame]
Jamie Hannaford21a3eb12014-11-03 10:34:29 +01001package nodes
2
Jamie Hannaford940cece2014-11-03 10:59:36 +01003// 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 Hannaford21a3eb12014-11-03 10:34:29 +01005type Node struct {
Jamie Hannaford940cece2014-11-03 10:59:36 +01006 // 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 Hannaford21a3eb12014-11-03 10:34:29 +010019 Condition string
Jamie Hannaford940cece2014-11-03 10:59:36 +010020
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 Hannaford21a3eb12014-11-03 10:34:29 +010027}
Jamie Hannaford940cece2014-11-03 10:59:36 +010028
29// Type indicates whether the node is of a PRIMARY or SECONDARY nature.
30type Type string
31
32const (
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
46type Condition string
47
48const (
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
67type Status string
68
69const (
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)