Skip to content

Commit

Permalink
Add the ingress-postgres-outbox ingress rule
Browse files Browse the repository at this point in the history
This is currently in Alpha. It wasn't previously added so it makes sense to add it whilst I'm working on the MongoDB ingress rule.
  • Loading branch information
graham-russell committed Dec 11, 2024
1 parent b98f465 commit 9282214
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ingress_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func (r *IngressRule) UnmarshalJSON(data []byte) error {
var t IngressMongoTarget
err = json.Unmarshal(raw.Target, &t)
r.Target = &t
case "ingress-postgres-outbox":
var t IngressPostgresOutboxTarget
err = json.Unmarshal(raw.Target, &t)
r.Target = &t
default:
return fmt.Errorf("unknown rule type \"%s\"", raw.RuleType)
}
Expand Down Expand Up @@ -124,6 +128,36 @@ func (s *IngressMongoTarget) TargetType() string {
return "ingress/mongodb"
}

type IngressPostgresOutboxTarget struct {
// The URL for your Postgres database.
Url string `json:"url,omitempty"`
// Schema for the outbox table in your database which allows for the
// reliable publication of an ordered sequence of change event messages
// over Ably.
OutboxTableSchema string `json:"outboxTableSchema,omitempty"`
// Name for the outbox table.
OutboxTableName string `json:"outboxTableName,omitempty"`
// Schema for the nodes table in your database to allow for operation as a
// cluster to provide fault tolerance.
NodesTableSchema string `json:"nodesTableSchema,omitempty"`
// Name for the nodes table.
NodesTableName string `json:"nodesTableName,omitempty"`
// Determines the level of protection provided by the SSL connection.
// Options are: prefer, require, verify-ca, verify-full;
// default value is prefer.
SslMode string `json:"sslMode,omitempty"`
// Optional. Specifies the SSL certificate authority (CA) certificates.
// Required if SSL mode is verify-ca or verify-full.
SslRootCert string `json:"sslRootCert,omitempty"`
// The primary data center in which to run the integration rule.
PrimarySite string `json:"primarySite,omitempty"`
}

// IngressPostgresTarget implements the Target interface.
func (s *IngressPostgresOutboxTarget) TargetType() string {
return "ingress-postgres-outbox"
}

// Creates an Ingress rule for the application with the specified application ID.
func (c *Client) CreateIngressRule(appID string, rule *NewIngressRule) (Rule, error) {
var out Rule
Expand Down
15 changes: 15 additions & 0 deletions ingress_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ func TestRuleIngressMongo(t *testing.T) {
testIngressRule(t, target)
}

func TestRuleIngressPostgresOutbox(t *testing.T) {
target := &IngressPostgresOutboxTarget{
Url: "postgres://user:[email protected]:5432/your-database-name",
OutboxTableSchema: "public",
OutboxTableName: "outbox",
NodesTableSchema: "public",
NodesTableName: "nodes",
SslMode: "prefer",
SslRootCert: "-----BEGIN CERTIFICATE----- MIIFiTCCA3GgAwIBAgIUYO1Lomxzj7VRawWwEFiQht9OLpUwDQYJKoZIhvcNAQEL BQAwTDELMAkGA1UEBhMCVVMxETAPBgNVBAgMCE1pY2hpZ2FuMQ8wDQYDVQQHDAZX ...snip... TOfReTlUQzgpXRW5h3n2LVXbXQhPGcVitb88Cm2R8cxQwgB1VncM8yvmKhREo2tz 7Y+sUx6eIl4dlNl9kVrH1TD3EwwtGsjUNlFSZhg= -----END CERTIFICATE-----",
PrimarySite: "us-east-1-A",
}

testIngressRule(t, target)
}

func testIngressRule(t *testing.T, target Target) {
client, _ := newTestClient(t)
app := newTestApp(t, &client)
Expand Down

0 comments on commit 9282214

Please sign in to comment.