Skip to content

Commit f226fb8

Browse files
authored
Deprecate admin server DBOSConfig settings (#392)
1 parent 707a950 commit f226fb8

4 files changed

Lines changed: 159 additions & 0 deletions

File tree

transact-spring-boot-starter/src/main/java/dev/dbos/transact/spring/DBOSAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public DBOSWorkflowRegistrar dbosWorkflowRegistrar(
103103
return new DBOSWorkflowRegistrar(dbos, applicationContext);
104104
}
105105

106+
@SuppressWarnings("removal")
106107
private DBOSConfig buildConfig(DBOSProperties props, String springAppName) {
107108
String appName =
108109
props.getApplication().getName() != null ? props.getApplication().getName() : springAppName;

transact-spring-boot-starter/src/test/java/dev/dbos/transact/spring/DBOSAutoConfigurationTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void dbosConfigReflectsDatasourceProperties() {
6666
}
6767

6868
@Test
69+
@SuppressWarnings("removal")
6970
void dbosConfigReflectsOptionalProperties() {
7071
runner
7172
.withPropertyValues(

transact/src/main/java/dev/dbos/transact/config/DBOSConfig.java

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,49 @@
1717
import org.jspecify.annotations.NonNull;
1818
import org.jspecify.annotations.Nullable;
1919

20+
/**
21+
* Immutable configuration for a DBOS application instance.
22+
*
23+
* <p>Use {@link #defaults(String)} or {@link #defaultsFromEnv(String)} to obtain a base
24+
* configuration, then chain {@code with*} methods to set individual options:
25+
*
26+
* <pre>{@code
27+
* DBOSConfig config = DBOSConfig.defaults("my-app")
28+
* .withDatabaseUrl("jdbc:postgresql://localhost:5432/mydb")
29+
* .withMigrate(true);
30+
* }</pre>
31+
*
32+
* @param appName unique name for this application; must not be null or empty
33+
* @param databaseUrl JDBC URL of the PostgreSQL database; may be {@code null} when a {@link
34+
* DataSource} is provided instead
35+
* @param dbUser PostgreSQL username; may be {@code null} to rely on driver defaults
36+
* @param dbPassword PostgreSQL password; masked in {@link #toString()}
37+
* @param dataSource pre-configured {@link DataSource} to use instead of {@code databaseUrl}, {@code
38+
* dbUser}, and {@code dbPassword}
39+
* @param adminServer whether to start the built-in admin HTTP server; deprecated and will be
40+
* removed before 1.0 — use DBOS Conductor instead
41+
* @param adminServerPort port for the built-in admin HTTP server; deprecated and will be removed
42+
* before 1.0 — use DBOS Conductor instead
43+
* @param migrate whether to run database migrations on startup
44+
* @param conductorKey API key for DBOS Conductor; must not be empty if non-null
45+
* @param conductorDomain custom hostname for DBOS Conductor; must not be empty if non-null
46+
* @param conductorExecutorMetadata arbitrary key-value metadata attached to this executor's
47+
* registration in Conductor
48+
* @param appVersion application version string used for versioned workflow routing; must not be
49+
* empty if non-null
50+
* @param executorId stable identifier for this executor instance; must not be empty if non-null
51+
* @param databaseSchema PostgreSQL schema used for DBOS system tables; {@code null} uses the
52+
* default schema
53+
* @param enablePatching whether to enable workflow patching
54+
* @param listenQueues names of queues this executor should dequeue work from; an empty set means
55+
* listen on all queues
56+
* @param serializer custom {@link DBOSSerializer} for workflow arguments and return values; {@code
57+
* null} uses the default JSON serializer
58+
* @param schedulerPollingInterval how often the cron scheduler polls for due tasks; {@code null}
59+
* uses the system default
60+
* @param useListenNotify whether to use PostgreSQL {@code LISTEN}/{@code NOTIFY} for real-time
61+
* workflow wake-ups instead of polling
62+
*/
2063
public record DBOSConfig(
2164
@NonNull String appName,
2265
@Nullable String databaseUrl,
@@ -59,6 +102,24 @@ public record DBOSConfig(
59102
listenQueues = (listenQueues == null) ? Set.of() : Set.copyOf(listenQueues);
60103
}
61104

105+
/**
106+
* @deprecated The built-in admin server will be removed before 1.0. Use DBOS Conductor instead.
107+
*/
108+
@Deprecated(since = "0.9", forRemoval = true)
109+
@Override
110+
public boolean adminServer() {
111+
return adminServer;
112+
}
113+
114+
/**
115+
* @deprecated The built-in admin server will be removed before 1.0. Use DBOS Conductor instead.
116+
*/
117+
@Deprecated(since = "0.9", forRemoval = true)
118+
@Override
119+
public int adminServerPort() {
120+
return adminServerPort;
121+
}
122+
62123
// Copy constructor
63124
public DBOSConfig(DBOSConfig other) {
64125
this(
@@ -85,6 +146,16 @@ public DBOSConfig(DBOSConfig other) {
85146
other.useListenNotify);
86147
}
87148

149+
/**
150+
* Returns a {@link DBOSConfig} with sensible defaults for the given application name.
151+
*
152+
* <p>Migrations are enabled and {@code LISTEN}/{@code NOTIFY} is used for workflow wake-ups. No
153+
* database connection details are pre-filled; supply them with {@link #withDatabaseUrl}, {@link
154+
* #withDbUser}/{@link #withDbPassword}, or {@link #withDataSource}.
155+
*
156+
* @param appName unique application name; must not be null or empty
157+
* @return a default {@link DBOSConfig} for the given name
158+
*/
88159
public static @NonNull DBOSConfig defaults(@NonNull String appName) {
89160
return new DBOSConfig(
90161
appName, null, null, null, null, false, // adminServer
@@ -93,6 +164,20 @@ public DBOSConfig(DBOSConfig other) {
93164
null, null, null, null, null, null, false, null, null, null, true); // useListenNotify
94165
}
95166

167+
/**
168+
* Returns a {@link DBOSConfig} populated from standard environment variables.
169+
*
170+
* <p>Reads the following variables:
171+
*
172+
* <ul>
173+
* <li>{@code DBOS_SYSTEM_JDBC_URL} — JDBC URL for the database
174+
* <li>{@code PGUSER} — database username (defaults to {@code "postgres"} if absent)
175+
* <li>{@code PGPASSWORD} — database password
176+
* </ul>
177+
*
178+
* @param appName unique application name; must not be null or empty
179+
* @return a {@link DBOSConfig} seeded from environment variables
180+
*/
96181
public static @NonNull DBOSConfig defaultsFromEnv(@NonNull String appName) {
97182
String databaseUrl = System.getenv(Constants.SYSTEM_JDBC_URL_ENV_VAR);
98183
String dbUser = System.getenv(Constants.POSTGRES_USER_ENV_VAR);
@@ -104,6 +189,7 @@ public DBOSConfig(DBOSConfig other) {
104189
.withDbPassword(dbPassword);
105190
}
106191

192+
/** Returns a copy of this config with {@code appName} set to {@code v}. */
107193
public @NonNull DBOSConfig withAppName(@NonNull String v) {
108194
return new DBOSConfig(
109195
v,
@@ -127,6 +213,7 @@ public DBOSConfig(DBOSConfig other) {
127213
useListenNotify);
128214
}
129215

216+
/** Returns a copy of this config with {@code databaseUrl} set to {@code v}. */
130217
public @NonNull DBOSConfig withDatabaseUrl(@Nullable String v) {
131218
return new DBOSConfig(
132219
appName,
@@ -150,6 +237,7 @@ public DBOSConfig(DBOSConfig other) {
150237
useListenNotify);
151238
}
152239

240+
/** Returns a copy of this config with {@code dbUser} set to {@code v}. */
153241
public @NonNull DBOSConfig withDbUser(@Nullable String v) {
154242
return new DBOSConfig(
155243
appName,
@@ -173,6 +261,7 @@ public DBOSConfig(DBOSConfig other) {
173261
useListenNotify);
174262
}
175263

264+
/** Returns a copy of this config with {@code dbPassword} set to {@code v}. */
176265
public @NonNull DBOSConfig withDbPassword(@Nullable String v) {
177266
return new DBOSConfig(
178267
appName,
@@ -196,6 +285,12 @@ public DBOSConfig(DBOSConfig other) {
196285
useListenNotify);
197286
}
198287

288+
/**
289+
* Returns a copy of this config with {@code dataSource} set to {@code v}.
290+
*
291+
* <p>When a {@link DataSource} is provided it takes precedence over {@code databaseUrl}, {@code
292+
* dbUser}, and {@code dbPassword}.
293+
*/
199294
public @NonNull DBOSConfig withDataSource(@Nullable DataSource v) {
200295
return new DBOSConfig(
201296
appName,
@@ -219,6 +314,12 @@ public DBOSConfig(DBOSConfig other) {
219314
useListenNotify);
220315
}
221316

317+
/**
318+
* Returns a copy of this config with {@code adminServer} set to {@code v}.
319+
*
320+
* @deprecated The built-in admin server will be removed before 1.0. Use DBOS Conductor instead.
321+
*/
322+
@Deprecated(since = "0.9", forRemoval = true)
222323
public @NonNull DBOSConfig withAdminServer(boolean v) {
223324
return new DBOSConfig(
224325
appName,
@@ -242,6 +343,12 @@ public DBOSConfig(DBOSConfig other) {
242343
useListenNotify);
243344
}
244345

346+
/**
347+
* Returns a copy of this config with {@code adminServerPort} set to {@code v}.
348+
*
349+
* @deprecated The built-in admin server will be removed before 1.0. Use DBOS Conductor instead.
350+
*/
351+
@Deprecated(since = "0.9", forRemoval = true)
245352
public @NonNull DBOSConfig withAdminServerPort(int v) {
246353
return new DBOSConfig(
247354
appName,
@@ -265,6 +372,7 @@ public DBOSConfig(DBOSConfig other) {
265372
useListenNotify);
266373
}
267374

375+
/** Returns a copy of this config with {@code migrate} set to {@code v}. */
268376
public @NonNull DBOSConfig withMigrate(boolean v) {
269377
return new DBOSConfig(
270378
appName,
@@ -288,6 +396,7 @@ public DBOSConfig(DBOSConfig other) {
288396
useListenNotify);
289397
}
290398

399+
/** Returns a copy of this config with {@code conductorKey} set to {@code v}. */
291400
public @NonNull DBOSConfig withConductorKey(@Nullable String v) {
292401
return new DBOSConfig(
293402
appName,
@@ -311,6 +420,7 @@ public DBOSConfig(DBOSConfig other) {
311420
useListenNotify);
312421
}
313422

423+
/** Returns a copy of this config with {@code conductorDomain} set to {@code v}. */
314424
public @NonNull DBOSConfig withConductorDomain(@Nullable String v) {
315425
return new DBOSConfig(
316426
appName,
@@ -334,6 +444,7 @@ public DBOSConfig(DBOSConfig other) {
334444
useListenNotify);
335445
}
336446

447+
/** Returns a copy of this config with {@code conductorExecutorMetadata} set to {@code v}. */
337448
public @NonNull DBOSConfig withConductorExecutorMetadata(@Nullable Map<String, Object> v) {
338449
return new DBOSConfig(
339450
appName,
@@ -357,6 +468,7 @@ public DBOSConfig(DBOSConfig other) {
357468
useListenNotify);
358469
}
359470

471+
/** Returns a copy of this config with {@code appVersion} set to {@code v}. */
360472
public @NonNull DBOSConfig withAppVersion(@Nullable String v) {
361473
return new DBOSConfig(
362474
appName,
@@ -380,6 +492,7 @@ public DBOSConfig(DBOSConfig other) {
380492
useListenNotify);
381493
}
382494

495+
/** Returns a copy of this config with {@code executorId} set to {@code v}. */
383496
public @NonNull DBOSConfig withExecutorId(@Nullable String v) {
384497
return new DBOSConfig(
385498
appName,
@@ -403,6 +516,7 @@ public DBOSConfig(DBOSConfig other) {
403516
useListenNotify);
404517
}
405518

519+
/** Returns a copy of this config with {@code databaseSchema} set to {@code v}. */
406520
public @NonNull DBOSConfig withDatabaseSchema(@Nullable String v) {
407521
return new DBOSConfig(
408522
appName,
@@ -426,14 +540,17 @@ public DBOSConfig(DBOSConfig other) {
426540
useListenNotify);
427541
}
428542

543+
/** Returns a copy of this config with {@code enablePatching} set to {@code true}. */
429544
public @NonNull DBOSConfig withEnablePatching() {
430545
return this.withEnablePatching(true);
431546
}
432547

548+
/** Returns a copy of this config with {@code enablePatching} set to {@code false}. */
433549
public @NonNull DBOSConfig withDisablePatching() {
434550
return this.withEnablePatching(false);
435551
}
436552

553+
/** Returns a copy of this config with {@code enablePatching} set to {@code v}. */
437554
public @NonNull DBOSConfig withEnablePatching(boolean v) {
438555
return new DBOSConfig(
439556
appName,
@@ -457,22 +574,52 @@ public DBOSConfig(DBOSConfig other) {
457574
useListenNotify);
458575
}
459576

577+
/**
578+
* Returns a copy of this config with the built-in admin server enabled.
579+
*
580+
* @deprecated The built-in admin server will be removed before 1.0. Use DBOS Conductor instead.
581+
*/
582+
@Deprecated(since = "0.9", forRemoval = true)
460583
public @NonNull DBOSConfig enableAdminServer() {
461584
return withAdminServer(true);
462585
}
463586

587+
/**
588+
* Returns a copy of this config with the built-in admin server disabled.
589+
*
590+
* @deprecated The built-in admin server will be removed before 1.0. Use DBOS Conductor instead.
591+
*/
592+
@Deprecated(since = "0.9", forRemoval = true)
464593
public @NonNull DBOSConfig disableAdminServer() {
465594
return withAdminServer(false);
466595
}
467596

597+
/**
598+
* Returns a copy of this config with {@code queue} added to the set of listened queues. Removes
599+
* the listen-on-all-queues default if this is the first queue specified.
600+
*
601+
* @param queue the queue to add; must not be null
602+
*/
468603
public @NonNull DBOSConfig withListenQueue(@NonNull Queue queue) {
469604
return withListenQueues(new String[] {queue.name()});
470605
}
471606

607+
/**
608+
* Returns a copy of this config with {@code queueName} added to the set of listened queues.
609+
* Removes the listen-on-all-queues default if this is the first queue specified.
610+
*
611+
* @param queueName the queue name to add; must not be null
612+
*/
472613
public @NonNull DBOSConfig withListenQueue(@NonNull String queueName) {
473614
return withListenQueues(new String[] {queueName});
474615
}
475616

617+
/**
618+
* Returns a copy of this config with each queue in {@code queues} added to the listened set.
619+
* Removes the listen-on-all-queues default if this is the first queue specified.
620+
*
621+
* @param queues the queues to add; {@code null} entries are ignored
622+
*/
476623
public @NonNull DBOSConfig withListenQueues(@Nullable Queue... queues) {
477624
var names =
478625
Arrays.stream(Objects.requireNonNullElseGet(queues, () -> new Queue[0]))
@@ -481,6 +628,12 @@ public DBOSConfig(DBOSConfig other) {
481628
return withListenQueues(names.toArray(String[]::new));
482629
}
483630

631+
/**
632+
* Returns a copy of this config with each name in {@code queueNames} added to the listened set.
633+
* Removes the listen-on-all-queues default if this is the first queue specified.
634+
*
635+
* @param queueNames the queue names to add; {@code null} entries are ignored
636+
*/
484637
public @NonNull DBOSConfig withListenQueues(@Nullable String... queueNames) {
485638
var v =
486639
Stream.concat(
@@ -510,6 +663,7 @@ public DBOSConfig(DBOSConfig other) {
510663
useListenNotify);
511664
}
512665

666+
/** Returns a copy of this config with {@code serializer} set to {@code v}. */
513667
public @NonNull DBOSConfig withSerializer(@Nullable DBOSSerializer v) {
514668
return new DBOSConfig(
515669
appName,
@@ -533,6 +687,7 @@ public DBOSConfig(DBOSConfig other) {
533687
useListenNotify);
534688
}
535689

690+
/** Returns a copy of this config with {@code schedulerPollingInterval} set to {@code v}. */
536691
public @NonNull DBOSConfig withSchedulerPollingInterval(@Nullable Duration v) {
537692
return new DBOSConfig(
538693
appName,
@@ -556,6 +711,7 @@ public DBOSConfig(DBOSConfig other) {
556711
useListenNotify);
557712
}
558713

714+
/** Returns a copy of this config with {@code useListenNotify} set to {@code v}. */
559715
public @NonNull DBOSConfig withUseListenNotify(boolean v) {
560716
return new DBOSConfig(
561717
appName,

transact/src/main/java/dev/dbos/transact/execution/DBOSExecutor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ public DBOSExecutor(DBOSConfig config) {
157157
}
158158
}
159159

160+
@SuppressWarnings("removal")
160161
public void start(
161162
DBOS dbos,
162163
Set<DBOSLifecycleListener> listenerSet,

0 commit comments

Comments
 (0)