Skip to content

Commit a566728

Browse files
authored
feat(rails): expose global.database.preparedStatement (#218)
1 parent 55e0d91 commit a566728

8 files changed

Lines changed: 48 additions & 0 deletions

File tree

charts/lago-config/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ A Helm chart for Kubernetes
5050
|-----|------|---------|-------------|
5151
| global.database.uri | string | `""` | PostgreSQL connection URI |
5252
| global.database.pool | int | `20` | Database connection pool size |
53+
| global.database.preparedStatement | bool | `nil` | Enable ActiveRecord prepared statements. Leave unset to use the Rails default (`true`); set to `false` when running behind a connection pooler that can't multiplex sessions issuing prepared statements. Renders the `DATABASE_PREPARED_STATEMENTS` env var on Rails pods only when explicitly set. |
5354

5455
### Encryption
5556

charts/lago-config/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ global:
7171
# -- Database connection pool size
7272
# @section -- Database
7373
pool: 20
74+
# -- (bool) Enable ActiveRecord prepared statements. Leave unset to use the
75+
# Rails default (`true`); set to `false` when running behind a connection
76+
# pooler that can't multiplex sessions issuing prepared statements. Renders
77+
# the `DATABASE_PREPARED_STATEMENTS` env var on Rails pods only when
78+
# explicitly set.
79+
# @section -- Database
80+
preparedStatement:
7481

7582
encryption:
7683
# -- Primary encryption key (`openssl rand -hex 16`)

charts/lago-rails/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ A Helm chart for Kubernetes
2222
| config.log.level | string | `"info"` | Log level (`debug`, `info`, `warn`, `error`) |
2323
| config.log.stdout | bool | `true` | Log to stdout |
2424
| config.database.pool | int | `nil` | Override the global database pool size for this instance |
25+
| config.database.preparedStatement | bool | `nil` | Override `global.database.preparedStatement` for this instance |
2526
| config.otel.enabled | bool | `false` | Enable OpenTelemetry tracing |
2627
| config.otel.endpoint | string | `nil` | OpenTelemetry collector endpoint |
2728
| config.otel.serviceName | string | `nil` | OpenTelemetry service name |

charts/lago-rails/templates/deployment.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ spec:
6161
value: {{ .Values.config.log.stdout | quote }}
6262
- name: DATABASE_POOL
6363
value: {{ default .Values.global.database.pool .Values.config.database.pool | quote }}
64+
{{/* Per-instance override wins over the umbrella default. */}}
65+
{{- if kindIs "bool" .Values.config.database.preparedStatement }}
66+
- name: DATABASE_PREPARED_STATEMENTS
67+
value: {{ .Values.config.database.preparedStatement | quote }}
68+
{{/* Fall back to the global value shared across every Rails pod. */}}
69+
{{- else if kindIs "bool" .Values.global.database.preparedStatement }}
70+
- name: DATABASE_PREPARED_STATEMENTS
71+
value: {{ .Values.global.database.preparedStatement | quote }}
72+
{{- end }}
6473
- name: LAGO_SIDEKIQ_PRO_REQUIRED
6574
value: {{ .Values.global.sidekiq.pro | quote }}
6675
- name: LAGO_SIDEKIQ_WEB

charts/lago-rails/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ global:
6969
# -- Database connection pool size
7070
# @section -- Database
7171
pool: 20
72+
# -- (bool) Enable ActiveRecord prepared statements. Leave unset to use the
73+
# Rails default (`true`); set to `false` when running behind a connection
74+
# pooler that can't multiplex sessions issuing prepared statements. Renders
75+
# the `DATABASE_PREPARED_STATEMENTS` env var on Rails pods only when
76+
# explicitly set.
77+
# @section -- Database
78+
preparedStatement:
7279

7380
encryption:
7481
# -- Primary encryption key (`openssl rand -hex 16`)
@@ -320,6 +327,9 @@ config:
320327
# -- (int) Override the global database pool size for this instance
321328
# @section -- Config
322329
pool:
330+
# -- (bool) Override `global.database.preparedStatement` for this instance
331+
# @section -- Config
332+
preparedStatement:
323333

324334
otel:
325335
# -- Enable OpenTelemetry tracing

charts/lago/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ A Helm chart for Kubernetes
236236
| migrate.config.log.level | string | `"info"` | Log level (`debug`, `info`, `warn`, `error`) |
237237
| migrate.config.log.stdout | bool | `true` | Log to stdout |
238238
| migrate.config.database.pool | int | `nil` | Override the global database pool size for this instance |
239+
| migrate.config.database.preparedStatement | bool | `nil` | Override `global.database.preparedStatement` for this instance |
239240

240241
### Create Topics Job
241242

charts/lago/templates/migrate-job.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ spec:
6565
value: {{ default .Values.global.lago.env .Values.migrate.config.env }}
6666
- name: DATABASE_POOL
6767
value: {{ default .Values.global.database.pool .Values.migrate.config.database.pool | quote }}
68+
{{/* Per-instance override wins over the umbrella default. */}}
69+
{{- if kindIs "bool" .Values.migrate.config.database.preparedStatement }}
70+
- name: DATABASE_PREPARED_STATEMENTS
71+
value: {{ .Values.migrate.config.database.preparedStatement | quote }}
72+
{{/* Fall back to the global value shared across every Rails pod. */}}
73+
{{- else if kindIs "bool" .Values.global.database.preparedStatement }}
74+
- name: DATABASE_PREPARED_STATEMENTS
75+
value: {{ .Values.global.database.preparedStatement | quote }}
76+
{{- end }}
6877
- name: LAGO_LOG_LEVEL
6978
value: {{ .Values.migrate.config.log.level }}
7079
- name: RAILS_LOG_TO_STDOUT

charts/lago/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ global:
7474
# -- Database connection pool size
7575
# @section -- Database
7676
pool: 20
77+
# -- (bool) Enable ActiveRecord prepared statements. Leave unset to use the
78+
# Rails default (`true`); set to `false` when running behind a connection
79+
# pooler that can't multiplex sessions issuing prepared statements. Renders
80+
# the `DATABASE_PREPARED_STATEMENTS` env var on Rails pods only when
81+
# explicitly set.
82+
# @section -- Database
83+
preparedStatement:
7784

7885
encryption:
7986
# -- Primary encryption key (`openssl rand -hex 16`)
@@ -705,6 +712,9 @@ migrate:
705712
# -- (int) Override the global database pool size for this instance
706713
# @section -- Database Migration / Config
707714
pool:
715+
# -- (bool) Override `global.database.preparedStatement` for this instance
716+
# @section -- Database Migration / Config
717+
preparedStatement:
708718
image:
709719
# -- Migration job image repository
710720
# @section -- Database Migration

0 commit comments

Comments
 (0)