kislerdm / diagramastext

Application to streamline diagram generation using plain English instructions instead of code
https://diagramastext.dev
Apache License 2.0
26 stars 1 forks source link

Migrate from Neon to Aurora #41

Closed kislerdm closed 1 year ago

kislerdm commented 1 year ago

Problem

@deim and I discovered that Neon connection goes down for unknown reasons during pairing session.

Proposed Solution

Migrate to AWS RDS Aurora

kislerdm commented 1 year ago

The issue was related to wrong db connection management.

Was

func handler(
    clientModel core.ClientInputToGraph, clientDiagram core.ClientGraphToDiagram, corsHeaders corsHeaders,
    clientStorage core.ClientStorage,
) func(
    ctx context.Context, req events.APIGatewayProxyRequest,
) (events.APIGatewayProxyResponse, error) {
    return func(
        ctx context.Context, req events.APIGatewayProxyRequest,
    ) (events.APIGatewayProxyResponse, error) {
            // connection closed after the first invocation
        defer func() { _ = clientStorage.Close(ctx) }()
            /* rest of the code */
}

Is

func main() {
    /* rest of the code */
    // connection is closed on lambda container termination
    ctx, cancelFn := context.WithTimeout(context.Background(), time.Second*10)
    defer cancelFn()
    defer func() { _ = clientStorage.Close(ctx) }()
}