Skip to content

Commit f1afa73

Browse files
committed
feat: group instance status fields
Groups the instance status fields into logical sections so that they're easier to read. PLAT-86
1 parent b8c6248 commit f1afa73

File tree

12 files changed

+5221
-3727
lines changed

12 files changed

+5221
-3727
lines changed

api/design/instance.go

Lines changed: 77 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,59 @@ import (
44
g "goa.design/goa/v3/dsl"
55
)
66

7+
var InstanceConnectionInfo = g.Type("InstanceConnectionInfo", func() {
8+
g.Description("Connection information for a pgEdge instance.")
9+
g.Attribute("hostname", g.String, func() {
10+
g.Description("The hostname of the host that's running this instance.")
11+
g.Example("i-0123456789abcdef.ec2.internal")
12+
})
13+
g.Attribute("ipv4_address", g.String, func() {
14+
g.Description("The IPv4 address of the host that's running this instance.")
15+
g.Format(g.FormatIPv4)
16+
g.Example("10.24.34.0")
17+
})
18+
g.Attribute("port", g.Int, func() {
19+
g.Description("The host port that Postgres is listening on for this instance.")
20+
g.Example(5432)
21+
})
22+
})
23+
24+
var InstancePostgresStatus = g.Type("InstancePostgresStatus", func() {
25+
g.Description("Postgres status information for a pgEdge instance.")
26+
g.Attribute("version", g.String, func() {
27+
g.Description("The version of Postgres for this instance.")
28+
g.Example("17.5")
29+
})
30+
g.Attribute("patroni_state", g.String, func() {
31+
g.Enum(
32+
"stopping",
33+
"stopped",
34+
"stop failed",
35+
"crashed",
36+
"running",
37+
"starting",
38+
"start failed",
39+
"restarting",
40+
"restart failed",
41+
"initializing new cluster",
42+
"initdb failed",
43+
"running custom bootstrap script",
44+
"custom bootstrap failed",
45+
"creating replica",
46+
"unknown",
47+
)
48+
})
49+
g.Attribute("role", g.String, func() {
50+
g.Enum("replica", "primary")
51+
})
52+
g.Attribute("pending_restart", g.Boolean, func() {
53+
g.Description("True if this instance is pending to be restarted from a configuration change.")
54+
})
55+
g.Attribute("patroni_paused", g.Boolean, func() {
56+
g.Description("True if Patroni has been paused for this instance.")
57+
})
58+
})
59+
760
var InstanceSubscription = g.Type("InstanceSubscription", func() {
861
g.Description("Status information for a Spock subscription.")
962
g.Attribute("provider_node", g.String, func() {
@@ -23,6 +76,21 @@ var InstanceSubscription = g.Type("InstanceSubscription", func() {
2376
g.Required("provider_node", "name", "status")
2477
})
2578

79+
var InstanceSpockStatus = g.Type("InstanceSpockStatus", func() {
80+
g.Description("Spock status information for a pgEdge instance.")
81+
g.Attribute("read_only", g.String, func() {
82+
g.Description("The current spock.readonly setting.")
83+
g.Example("off")
84+
})
85+
g.Attribute("version", g.String, func() {
86+
g.Description("The version of Spock for this instance.")
87+
g.Example("4.10.0")
88+
})
89+
g.Attribute("subscriptions", g.ArrayOf(InstanceSubscription), func() {
90+
g.Description("Status information for this instance's Spock subscriptions.")
91+
})
92+
})
93+
2694
var Instance = g.ResultType("Instance", func() {
2795
g.Description("An instance of pgEdge Postgres running on a host.")
2896
g.Attributes(func() {
@@ -63,61 +131,14 @@ var Instance = g.ResultType("Instance", func() {
63131
"unknown",
64132
)
65133
})
66-
g.Attribute("patroni_state", g.String, func() {
67-
g.Enum(
68-
"stopping",
69-
"stopped",
70-
"stop failed",
71-
"crashed",
72-
"running",
73-
"starting",
74-
"start failed",
75-
"restarting",
76-
"restart failed",
77-
"initializing new cluster",
78-
"initdb failed",
79-
"running custom bootstrap script",
80-
"custom bootstrap failed",
81-
"creating replica",
82-
"unknown",
83-
)
84-
})
85-
g.Attribute("role", g.String, func() {
86-
g.Enum("replica", "primary")
87-
})
88-
g.Attribute("read_only", g.String, func() {
89-
g.Description("The current spock.readonly setting.")
90-
g.Example("off")
91-
})
92-
g.Attribute("pending_restart", g.Boolean, func() {
93-
g.Description("True if this instance is pending to be restarted from a configuration change.")
94-
})
95-
g.Attribute("patroni_paused", g.Boolean, func() {
96-
g.Description("True if Patroni has been paused for this instance.")
97-
})
98-
g.Attribute("postgres_version", g.String, func() {
99-
g.Description("The version of Postgres for this instance.")
100-
g.Example("17.1")
101-
})
102-
g.Attribute("spock_version", g.String, func() {
103-
g.Description("The version of Spock for this instance.")
104-
g.Example("4.0.9")
105-
})
106-
g.Attribute("hostname", g.String, func() {
107-
g.Description("The hostname of the host that's running this instance.")
108-
g.Example("i-0123456789abcdef.ec2.internal")
109-
})
110-
g.Attribute("ipv4_address", g.String, func() {
111-
g.Description("The IPv4 address of the host that's running this instance.")
112-
g.Format(g.FormatIPv4)
113-
g.Example("10.24.34.0")
134+
g.Attribute("connection_info", InstanceConnectionInfo, func() {
135+
g.Description("Connection information for the instance.")
114136
})
115-
g.Attribute("port", g.Int, func() {
116-
g.Description("The host port that Postgres is listening on for this instance.")
117-
g.Example(5432)
137+
g.Attribute("postgres", InstancePostgresStatus, func() {
138+
g.Description("Postgres status information for the instance.")
118139
})
119-
g.Attribute("subscriptions", g.ArrayOf(InstanceSubscription), func() {
120-
g.Description("Status information for this instance's Spock subscriptions.")
140+
g.Attribute("spock", InstanceSpockStatus, func() {
141+
g.Description("Spock status information for the instance.")
121142
})
122143
g.Attribute("error", g.String, func() {
123144
g.Description("An error message if the instance is in an error state.")
@@ -133,17 +154,9 @@ var Instance = g.ResultType("Instance", func() {
133154
g.Attribute("updated_at")
134155
g.Attribute("status_updated_at")
135156
g.Attribute("state")
136-
g.Attribute("patroni_state")
137-
g.Attribute("role")
138-
g.Attribute("read_only")
139-
g.Attribute("pending_restart")
140-
g.Attribute("patroni_paused")
141-
g.Attribute("postgres_version")
142-
g.Attribute("spock_version")
143-
g.Attribute("hostname")
144-
g.Attribute("ipv4_address")
145-
g.Attribute("port")
146-
g.Attribute("subscriptions")
157+
g.Attribute("connection_info")
158+
g.Attribute("postgres")
159+
g.Attribute("spock")
147160
g.Attribute("error")
148161
})
149162

0 commit comments

Comments
 (0)