Skip to content

Commit a548c44

Browse files
kraftpmaxdmlqianl15
authored
DBOS Transact (#95)
Signed-off-by: Qian Li <[email protected]> Signed-off-by: Peter Kraft <[email protected]> Co-authored-by: maxdml <[email protected]> Co-authored-by: Qian Li <[email protected]> Co-authored-by: Max dml <[email protected]>
1 parent c63d09b commit a548c44

26 files changed

+191
-83
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Thank you for considering contributing to the DBOS Documentation. We welcome con
77
To get started with DBOS-Docs, please read the [README](README.md).
88

99
You can contribute in many ways. Some simple ways are:
10-
* Open issues to report any bugs, questions, concern with the SDK, samples or documentation.
10+
* Open issues to report any bugs, questions, concern with DBOS Transact, samples or documentation.
1111
* Respond to issues with advice or suggestions.
1212
* Participate in discussions in our [Discord](https://discord.gg/fMwQjeW5zg) channel.
1313
* Contribute fixes and improvement to code, samples or documentation.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DBOS SDK Documentation
1+
# DBOS Documentation
22

33
### Local Development
44

docs/api-reference/_category_.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"position": 4,
44
"link": {
55
"type": "generated-index",
6-
"description": "A complete reference for the DBOS SDK."
6+
"description": "A complete reference for DBOS."
77
}
88
}

docs/api-reference/cli.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
sidebar_position: 1
3-
title: SDK CLI
4-
description: DBOS CLI reference
3+
title: DBOS Transact CLI
4+
description: DBOS Transact CLI reference
55
---
66

7-
The DBOS SDK CLI helps you run DBOS applications locally.
7+
The DBOS Transact CLI helps you run applications locally.
88

99
## Commands
1010

1111
---
1212

13-
### `npx dbos-sdk start`
13+
### `npx dbos start`
1414

1515
**Description:**
16-
This command launches the DBOS runtime and HTTP server to serve an application.
16+
This command launches the DBOS Transact runtime and HTTP server to serve an application.
1717
It registers all functions and serves all endpoints in classes exported from the specified entrypoint file (typically `src/operations.ts`).
1818
Parameters set from the command line take precedence over parameters set in the [configuration file](./configuration).
1919
You must compile your code (`npm run build`) before running this command.
@@ -40,25 +40,25 @@ This command initializes a new DBOS application from a template into a target di
4040

4141
---
4242

43-
### `npx dbos-sdk migrate`
43+
### `npx dbos migrate`
4444

4545
**Description:**
4646
Run all migration commands specified in your [configuration file](./configuration) to apply your application's schema to the database.
4747

4848
---
4949

50-
### `npx dbos-sdk rollback`
50+
### `npx dbos rollback`
5151

5252
**Description:**
5353
Run all rollback commands specified in your [configuration file](./configuration) to roll back the last batch of schema migrations.
5454

5555
---
5656

57-
### `npx dbos-sdk debug`
57+
### `npx dbos debug`
5858

5959
**Description:**
6060
This command launches the DBOS runtime in debug mode to replay a specified workflow.
61-
It is similar to `dbos-sdk start`, but instead of starting an HTTP server, it replays a single workflow and connects to a locally running DBOS [time travel debug proxy](../cloud-tutorials/timetravel-debugging.md#time-travel-with-dbos-sdk-cli-non-vs-code-users).
61+
It is similar to `dbos start`, but instead of starting an HTTP server, it replays a single workflow and connects to a locally running DBOS [time travel debug proxy](../cloud-tutorials/timetravel-debugging.md#time-travel-with-dbos-cli-non-vs-code-users).
6262
You must compile your code (`npm run build`) and start the debug proxy before running this command.
6363

6464
**Parameters:**

docs/api-reference/cloud-cli.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
sidebar_position: 1
3-
title: Cloud CLI
3+
title: DBOS Cloud CLI
44
description: DBOS Cloud CLI reference
55
---
66

docs/api-reference/configuration.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ database:
5454
5555
This section is used to specify DBOS runtime parameters.
5656
57-
- **port** (optional): The port from which to serve your functions. Defaults to `3000`. Using [`npx dbos-sdk start -p <port>`](./cli#npx-dbos-sdk-start) overrides this config parameter.
58-
- **entrypoint** (optional): The compiled Javascript file where DBOS looks for your application's code. At startup, the DBOS runtime automatically loads all classes exported from this file, serving their endpoints and registering their decorated functions. Defaults to `dist/operations.js`. Using [`npx dbos-sdk start -e <entrypoint-file>`](./cli#npx-dbos-sdk-start) overrides this config parameter.
57+
- **port** (optional): The port from which to serve your functions. Defaults to `3000`. Using [`npx dbos start -p <port>`](./cli#npx-dbos-start) overrides this config parameter.
58+
- **entrypoint** (optional): The compiled Javascript file where DBOS looks for your application's code. At startup, the DBOS runtime automatically loads all classes exported from this file, serving their endpoints and registering their decorated functions. Defaults to `dist/operations.js`. Using [`npx dbos start -e <entrypoint-file>`](./cli#npx-dbos-start) overrides this config parameter.
5959

6060
**Example**:
6161

@@ -85,7 +85,7 @@ You can use the configuration file to tune the behavior of DBOS logging facility
8585
Note all options in this section are optional and will, if not specified, use the default values indicated in the example below.
8686

8787
#### Logs
88-
- **logLevel**: Filters, by severity, what logs should be printed. Defaults to `'info'`. Using [`npx dbos-sdk start -l <logLevel>`](./cli#npx-dbos-sdk-start) overrides this config parameter.
88+
- **logLevel**: Filters, by severity, what logs should be printed. Defaults to `'info'`. Using [`npx dbos start -l <logLevel>`](./cli#npx-dbos-start) overrides this config parameter.
8989
- **addContextMetadata**: Enables the addition of contextual information, such as workflow identity UUID, to each log entry. Defaults to `true`.
9090
- **silent**: Silences the logger. Defaults to `false`.
9191

docs/api-reference/contexts.md

+18
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Many contexts inherit from `DBOSContext` and share its properties and methods.
3232
- [authenticatedRoles](#ctxtauthenticatedroles)
3333
- [assumedRole](#ctxtassumedrole)
3434
- [logger](#ctxtlogger)
35+
- [span](#ctxtspan)
3536

3637
### Methods
3738

@@ -106,6 +107,16 @@ readonly logger: DBOSLogger
106107
A reference to DBOS's logger.
107108
Please see our [logging tutorial](../tutorials/logging.md) for more information.
108109

110+
#### `ctxt.span`
111+
112+
```typescript
113+
readonly span: Span
114+
```
115+
116+
An [OpenTelemetry Span](https://opentelemetry.io/docs/concepts/signals/traces/#spans) associated with this context.
117+
You can assign custom trace attributes to this span.
118+
Please see the [Span API](https://github.com/open-telemetry/opentelemetry-js/blob/main/api/src/trace/span.ts) for more information.
119+
109120
#### `ctxt.getConfig(key, [defaultValue])`
110121

111122
```typescript
@@ -429,6 +440,7 @@ getConfig<T>(key: string, defaultValue?: T): T | undefined;
429440
#### Properties and Methods
430441
431442
- [logger](#middlewarecontextlogger)
443+
- [span](#middlewarecontextspan)
432444
- [koaContext](#middlewarecontextkoacontext)
433445
- [name](#middlewarecontextname)
434446
- [requiredRole](#middlewarecontextrequiredrole)
@@ -443,6 +455,12 @@ readonly logger: DBOSLogger;
443455
444456
`logger` is available to record any interesting successes, failures, or diagnostic information that occur during middleware processing.
445457
458+
#### `MiddlewareContext.span`
459+
```typescript
460+
readonly span: Span;
461+
```
462+
`span` is the tracing span in which the middleware is being executed.
463+
446464
#### `MiddlewareContext.koaContext`
447465
448466
```typescript

docs/api-reference/decorators.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ DBOS allows applications to supply functions to be invoked at points in the appl
456456
#### `@DBOSInitializer`
457457
This decorator is used to specify functions to be run at application instance initialization time.
458458
`@DBOSInitializer` is intended for uses such as validating configuration, establishing connections to external (non-database) services, and so on.
459-
It is not a good place for database schema migration, for that see our [migration commands](cli.md#npx-dbos-sdk-migrate).
459+
It is not a good place for database schema migration, for that see our [migration commands](cli.md#npx-dbos-migrate).
460460

461461
The argument to `@DBOSInitializer` should be of type [`InitContext`](contexts.md#initcontext).
462462

docs/api-reference/static-analysis.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ While the list of "gotchas" is long and easily neglected, the good news is that
1515
DBOS recommends using static analysis as an ingredient in a comprehensive security strategy. As adding rule enforcement to a large, established codebase can be a hassle, DBOS recommends using tools from the beginning of a project, and therefore includes tool configuration in its [demo applications](https://github.com/dbos-inc/dbos-demo-apps) and [quickstart templates](../getting-started/quickstart.md).
1616

1717
DBOS uses several techniques to ensure that static analysis is as productive as possible, with minimal hassle:
18-
* DBOS builds on popular frameworks, thereby leveraging community best-practices and tools integration.
18+
* DBOS Transact builds on popular frameworks, thereby leveraging community best-practices and tools integration.
1919
* DBOS focuses on analysis rules that detect incorrect API usage and potential security vulnerabilities, rather than nitpicking on coding style.
20-
* The DBOS SDK is designed for straightforward analysis, reporting, and suggestion of superior alternatives.
2120

2221
---
2322

@@ -30,7 +29,7 @@ Many DBOS=suggested coding practices can be enforced by a combination of `eslint
3029
### Installing And Configuring `eslint`
3130

3231
::::tip
33-
If you got started with the [DBOS SDK Quickstart](../getting-started/quickstart.md), `eslint` and required plugins are already installed.
32+
If you got started with the [quickstart](../getting-started/quickstart.md), `eslint` and required plugins are already installed.
3433
Plugins to support TypeScript and detect common vulerabilities are automatically installed with `@dbos-inc/eslint-plugin` as dependencies and do not need to be installed separately.
3534
::::
3635

@@ -91,7 +90,7 @@ Many programmers use `console` statements during the development and debugging p
9190

9291
The `no-console` rule, provided by the primary `eslint` package, is automatically enabled in all configs of the DBOS plugin.
9392

94-
Use of `console` should be removed from code prior to use in production. Activities such as logging should use [SDK logging facilities](../tutorials/logging.md), so that data remains structured and can be automatically collected in a central database.
93+
Use of `console` should be removed from code prior to use in production. Activities such as logging should use [DBOS Transact logging facilities](../tutorials/logging.md), so that data remains structured and can be automatically collected in a central database.
9594

9695
#### `no-eval`
9796
Interpreted languages like JavaScript support the ability to treat data directly as executable code. If arbitrary user data can become code, many of the negative security implications are obvious.
@@ -126,15 +125,15 @@ Some DBOS lint rules are provided in the [`@dbos-inc/eslint-plugin`](https://git
126125

127126
Calls to functions such as `Math.random()` are [nondeterministic](../tutorials/workflow-tutorial#determinism), and may interfere with consistent workflow results or the debugger.
128127

129-
Such operations should use functions provided by the SDK, or at a minimum, be encapsulated in a [Communicator](../tutorials/communicator-tutorial).
128+
Such operations should use functions provided by DBOS Transact, or at a minimum, be encapsulated in a [Communicator](../tutorials/communicator-tutorial).
130129

131130
This rule is enabled by default in all `@dbos-inc/eslint-plugin` configurations.
132131

133132
#### `@dbos-inc/detect-new-date`
134133

135134
Calls to functions such as `new Date()` are [nondeterministic](../tutorials/workflow-tutorial#determinism), and may interfere with transactional data, consistent workflow execution, or the debugger.
136135

137-
Such operations should use functions provided by the SDK, or at a minimum, be encapsulated in a [Communicator](../tutorials/communicator-tutorial).
136+
Such operations should use functions provided by DBOS Transact, or at a minimum, be encapsulated in a [Communicator](../tutorials/communicator-tutorial).
138137

139138
This rule is enabled by default in all `@dbos-inc/eslint-plugin` configurations.
140139

docs/api-reference/time-travel-debugger.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The default DBOS launch configuration includes both of these commands in the Tim
6464
"type": "node-terminal",
6565
"request": "launch",
6666
"name": "Time Travel Debug",
67-
"command": "npx dbos-sdk debug -x ${command:dbos-ttdbg.get-proxy-url} -u ${command:dbos-ttdbg.pick-workflow-id}",
67+
"command": "npx dbos debug -x ${command:dbos-ttdbg.get-proxy-url} -u ${command:dbos-ttdbg.pick-workflow-id}",
6868
"preLaunchTask": "npm: build"
6969
}
7070
```

docs/cloud-tutorials/application-management.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Run this command in your application root directory:
4343
npx dbos-cloud app deploy
4444
```
4545

46-
When you deploy an application, DBOS Cloud first runs [`npx dbos-sdk migrate`](../api-reference/cli.md#npx-dbos-sdk-migrate) on your application database to apply all schema migrations you've defined.
46+
When you deploy an application, DBOS Cloud first runs [`npx dbos migrate`](../api-reference/cli.md#npx-dbos-migrate) on your application database to apply all schema migrations you've defined.
4747
It then starts your application.
4848
After your application is deployed, DBOS Cloud hosts it at this URL, which is also printed by the deploy command:
4949

@@ -64,7 +64,7 @@ Be careful making breaking schema changes such as deleting or renaming a column&
6464
### Rolling Back Application Databases
6565

6666
To [roll back your application database](./database-management.md#database-schema-management), run `npx dbos-cloud app rollback`.
67-
This command works analagously to `deploy`, but instead of running `npx dbos-sdk migrate`, it runs [`npx dbos-sdk rollback`](../api-reference/cli.md#npx-dbos-sdk-rollback) to execute the rollback commands defined in your [configuration file](../api-reference/configuration.md#database).
67+
This command works analagously to `deploy`, but instead of running `npx dbos migrate`, it runs [`npx dbos rollback`](../api-reference/cli.md#npx-dbos-rollback) to execute the rollback commands defined in your [configuration file](../api-reference/configuration.md#database).
6868
It then updates your application code.
6969

7070
### Monitoring and Debugging Applications

docs/cloud-tutorials/database-management.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ database:
6969
rollback: ['npx knex migrate:down']
7070
```
7171
72-
To run your migrations locally, run `npx dbos-sdk migrate` or `npx dbos-sdk rollback`.
72+
To run your migrations locally, run `npx dbos migrate` or `npx dbos rollback`.
7373

74-
When you [deploy](./application-management.md#registering-and-deploying-applications) an application to DBOS Cloud it runs `npx dbos-sdk migrate` to apply all schema changes before starting your application or updating its code.
75-
When you [roll back](./application-management.md#rolling-back-application-databases) an application on DBOS Cloud, it runs `npx dbos-sdk rollback` to roll back schema changes before updating your application's code.
74+
When you [deploy](./application-management.md#registering-and-deploying-applications) an application to DBOS Cloud it runs `npx dbos migrate` to apply all schema changes before starting your application or updating its code.
75+
When you [roll back](./application-management.md#rolling-back-application-databases) an application on DBOS Cloud, it runs `npx dbos rollback` to roll back schema changes before updating your application's code.
7676

7777
:::info
7878
Be careful making breaking schema changes such as deleting or renaming a column&#8212;they may break active workflows running on a previous application version.

docs/cloud-tutorials/timetravel-debugging.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ inside VS Code for "DBOS"
3131
Once installed, the DBOS Time Travel Extension will automatically update as new releases are published to the VS Code Marketplace.
3232

3333
:::info
34-
If you're not a VS Code user, please see the section below on [Time Travel Debugging with the DBOS SDK CLI](#time-travel-with-dbos-sdk-cli-non-vs-code-users) below.
34+
If you're not a VS Code user, please see the section below on [Time Travel Debugging with the DBOS CLI](#time-travel-with-dbos-cli-non-vs-code-users) below.
3535
:::
3636

3737
### Launching a Debug Session
@@ -186,9 +186,9 @@ Currently, the time travel debugger supports stepping through any past workflows
186186

187187
For more information, please read the [debugger extension reference](../api-reference/time-travel-debugger).
188188

189-
## Time Travel with DBOS SDK CLI (Non-VS Code Users)
189+
## Time Travel with DBOS CLI (Non-VS Code Users)
190190

191-
For non-VS Code users, you can run the time-travel debugger manually through the DBOS SDK CLI.
191+
For non-VS Code users, you can run the time-travel debugger manually through the DBOS CLI.
192192

193193
### Manual Setup
194194

@@ -219,11 +219,11 @@ Open another terminal window, enter your application folder, compile your code,
219219
```bash
220220
cd <Your App Folder>/
221221
npm run build
222-
npx dbos-sdk debug -u <workflow UUID>
222+
npx dbos debug -u <workflow UUID>
223223
```
224224

225225
:::info
226-
Every time you modify your code, you need to recompile it before running the `dbos-sdk debug` command again.
226+
Every time you modify your code, you need to recompile it before running the `dbos debug` command again.
227227
:::
228228

229-
For more information on the debug command, please see our [references](../api-reference/cli.md#npx-dbos-sdk-debug)
229+
For more information on the debug command, please see our [references](../api-reference/cli.md#npx-dbos-debug)

docs/explanations/application-structure-explanation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ Once you've written your functions, there are two basic ways to call them:
103103
1. Any function (not just handlers) can be called from HTTP if it's annotated with the [`GetApi`](../api-reference/decorators#getapi) or [`PostApi`](../api-reference/decorators#postapi) decorators. See our [HTTP serving tutorial](../tutorials/http-serving-tutorial) for details.
104104
2. Handlers and workflows can invoke other functions via their contexts' `invoke` ([workflow](../api-reference/contexts#workflowctxtinvoketargetclass), [handler](../api-reference/contexts#handlerctxtinvoketargetclass-workflowuuid)) method.
105105

106-
To learn more about each individual type of function and what it can do, see our [tutorials](../category/dbos-sdk-tutorials/).
106+
To learn more about each individual type of function and what it can do, see our [tutorials](../category/dbos-transact-tutorials/).

docs/explanations/core-concepts.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
sidebar_position: 2
3-
description: Learn the core ideas underlying the DBOS SDK
3+
description: Learn the core ideas underlying DBOS Transact
44
---
55

6-
# SDK Core Concepts
6+
# DBOS Transact Core Concepts
77

8-
The DBOS SDK is a transactional serverless TypeScript framework that helps you develop stateful applications that work right by default.
8+
DBOS Transact is a transactional serverless TypeScript framework that helps you develop stateful applications that work right by default.
99
Its two main principles are inspired by the [DBOS research project from Stanford and MIT](https://dbos-project.github.io/):
1010

1111
1. **Store all application state in the database.** By managing database connections and transactions, DBOS makes it easy for you to store all your app state in the database so it can be safe, consistent, and durable. Under the hood, we use the database to manage the state of workflow execution as well as all [messages](../tutorials/workflow-communication-tutorial#messages-api) and [events](../tutorials/workflow-communication-tutorial#events-api).

0 commit comments

Comments
 (0)