Skip to content

Commit 055b0ec

Browse files
authored
feat: instance monitors (#42)
PLAT-33
2 parents a70da4a + 8f810a8 commit 055b0ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+8445
-4596
lines changed

api/design/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ var _ = g.Service("control-plane", func() {
162162
})
163163
})
164164

165-
g.Method("inspect-database", func() {
165+
g.Method("get-database", func() {
166166
g.Description("Returns information about a particular database in the cluster.")
167167
g.Payload(func() {
168168
g.Attribute("database_id", g.String, func() {
169-
g.Description("ID of the database to inspect.")
169+
g.Description("ID of the database to get.")
170170
g.Example("02f1a7db-fca8-4521-b57a-2a375c1ced51")
171171
})
172172
})

api/design/database.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ var Database = g.ResultType("Database", func() {
435435
})
436436
g.Attribute("instances", g.CollectionOf(Instance), func() {
437437
g.Description("All of the instances in the database.")
438-
g.View("abbreviated")
439438
})
440439
g.Attribute("spec", DatabaseSpec, func() {
441440
g.Description("The user-provided specification for the database.")
@@ -448,7 +447,9 @@ var Database = g.ResultType("Database", func() {
448447
g.Attribute("created_at")
449448
g.Attribute("updated_at")
450449
g.Attribute("state")
451-
g.Attribute("instances")
450+
g.Attribute("instances", func() {
451+
g.View("default")
452+
})
452453
g.Attribute("spec")
453454
})
454455

@@ -458,7 +459,9 @@ var Database = g.ResultType("Database", func() {
458459
g.Attribute("created_at")
459460
g.Attribute("updated_at")
460461
g.Attribute("state")
461-
g.Attribute("instances")
462+
g.Attribute("instances", func() {
463+
g.View("abbreviated")
464+
})
462465
})
463466

464467
g.Required("id", "created_at", "updated_at", "state")

api/design/instance.go

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,27 @@ import (
44
g "goa.design/goa/v3/dsl"
55
)
66

7-
var InstanceInterface = g.Type("InstanceInterface", func() {
8-
g.Attribute("network_type", g.String, func() {
9-
g.Description("The type of network for this interface.")
10-
g.Enum("docker", "host")
11-
g.Example("docker")
7+
var InstanceSubscription = g.Type("InstanceSubscription", func() {
8+
g.Description("Status information for a Spock subscription.")
9+
g.Attribute("provider_node", g.String, func() {
10+
g.Example("n2")
11+
g.Description("The Spock node name of the provider for this subscription.")
1212
})
13-
g.Attribute("network_id", g.String, func() {
14-
g.Description("The unique identifier of the network for this interface.")
15-
g.Example("l5imrq28sh6s")
13+
g.Attribute("name", g.String, func() {
14+
g.Example("sub_n1n2")
15+
g.Description("The name of the subscription.")
1616
})
17-
g.Attribute("hostname", g.String, func() {
18-
g.Description("The hostname of the instance on this interface.")
19-
g.Example("postgres-n1")
20-
})
21-
g.Attribute("ipv4_address", g.String, func() {
22-
g.Format(g.FormatIPv4)
23-
g.Description("The IPv4 address of the instance on this interface.")
24-
g.Example("10.1.0.113")
25-
})
26-
g.Attribute("port", g.Int, func() {
27-
g.Description("The Postgres port for the instance on this interface.")
28-
g.Example(5432)
17+
g.Attribute("status", g.String, func() {
18+
g.Example("replicating")
19+
g.Example("down")
20+
g.Description("The current status of the subscription.")
2921
})
3022

31-
g.Required("network_type", "port")
23+
g.Required("provider_node", "name", "status")
3224
})
3325

3426
var Instance = g.ResultType("Instance", func() {
27+
g.Description("An instance of pgEdge Postgres running on a host.")
3528
g.Attributes(func() {
3629
g.Attribute("id", g.String, func() {
3730
g.Format(g.FormatUUID)
@@ -53,17 +46,20 @@ var Instance = g.ResultType("Instance", func() {
5346
})
5447
g.Attribute("updated_at", g.String, func() {
5548
g.Format(g.FormatDateTime)
56-
g.Description("The time that the instance was last updated.")
49+
g.Description("The time that the instance was last modified.")
50+
})
51+
g.Attribute("status_updated_at", g.String, func() {
52+
g.Format(g.FormatDateTime)
53+
g.Description("The time that the instance status information was last updated.")
5754
})
5855
g.Attribute("state", g.String, func() {
5956
g.Enum(
6057
"creating",
6158
"modifying",
6259
"backing_up",
63-
"restoring",
64-
"deleting",
6560
"available",
6661
"degraded",
62+
"failed",
6763
"unknown",
6864
)
6965
})
@@ -89,8 +85,9 @@ var Instance = g.ResultType("Instance", func() {
8985
g.Attribute("role", g.String, func() {
9086
g.Enum("replica", "primary")
9187
})
92-
g.Attribute("read_only", g.Boolean, func() {
93-
g.Description("True if this instance is in read-only mode.")
88+
g.Attribute("read_only", g.String, func() {
89+
g.Description("The current spock.readonly setting.")
90+
g.Example("off")
9491
})
9592
g.Attribute("pending_restart", g.Boolean, func() {
9693
g.Description("True if this instance is pending to be restarted from a configuration change.")
@@ -106,8 +103,25 @@ var Instance = g.ResultType("Instance", func() {
106103
g.Description("The version of Spock for this instance.")
107104
g.Example("4.0.9")
108105
})
109-
g.Attribute("interfaces", g.ArrayOf(InstanceInterface), func() {
110-
g.Description("All interfaces that this instance serves on.")
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")
114+
})
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)
118+
})
119+
g.Attribute("subscriptions", g.ArrayOf(InstanceSubscription), func() {
120+
g.Description("Status information for this instance's Spock subscriptions.")
121+
})
122+
g.Attribute("error", g.String, func() {
123+
g.Description("An error message if the instance is in an error state.")
124+
g.Example("failed to get patroni status: connection refused")
111125
})
112126
})
113127

@@ -117,6 +131,7 @@ var Instance = g.ResultType("Instance", func() {
117131
g.Attribute("node_name")
118132
g.Attribute("created_at")
119133
g.Attribute("updated_at")
134+
g.Attribute("status_updated_at")
120135
g.Attribute("state")
121136
g.Attribute("patroni_state")
122137
g.Attribute("role")
@@ -125,7 +140,11 @@ var Instance = g.ResultType("Instance", func() {
125140
g.Attribute("patroni_paused")
126141
g.Attribute("postgres_version")
127142
g.Attribute("spock_version")
128-
g.Attribute("interfaces")
143+
g.Attribute("hostname")
144+
g.Attribute("ipv4_address")
145+
g.Attribute("port")
146+
g.Attribute("subscriptions")
147+
g.Attribute("error")
129148
})
130149

131150
g.View("abbreviated", func() {

api/gen/control_plane/client.go

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/gen/control_plane/endpoints.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)