Skip to content

Commit 17ee47d

Browse files
Rename module to database where appropriate (#277)
* clients connect to databases, not modules * the name is for the database, not the module * reducers are exposed by databases, not modules * don't name clients "modules" too * Modules have no state, the database has it * more database instead of client connection * databases are hosted, not modules * users interact with databases, not modules * fix typo * Apply suggestions from code review Co-authored-by: Tyler Cloutier <[email protected]> * Apply suggestions from code review Co-authored-by: Tyler Cloutier <[email protected]> --------- Co-authored-by: Tyler Cloutier <[email protected]>
1 parent 3d2c50c commit 17ee47d

18 files changed

+88
-88
lines changed

STYLE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ For example:
311311
>
312312
> You can supply your users with authorization tokens in several different ways; which one is best for you will depend on the needs of your app. [...] (I don't actually want to write a real answer to this question - pgoldman 2024-11-19.)
313313
>
314-
> #### Can my client connect to multiple modules at the same time?
314+
> #### Can my client connect to multiple databases at the same time?
315315
>
316-
> Yes! Your client can construct as many `DbConnection`s simultaneously as it wants to, each of which will operate independently. If you want to connect to two modules with different schemas, use `spacetime generate` to include bindings for both of them in your client project. Note that SpacetimeDB may reject multiple concurrent connections to the same module by a single client.
316+
> Yes! Your client can construct as many `DbConnection`s simultaneously as it wants to, each of which will operate independently. If you want to connect to two databases with different schemas, use `spacetime generate` to include bindings for both of them in your client project. Note that SpacetimeDB may reject multiple concurrent connections to the same database by a single client.
317317
318318
## Tutorial pages
319319
@@ -341,7 +341,7 @@ The first time a tutorial or series introduces a new type / function / method /
341341
342342
### Tutorial code
343343
344-
If the tutorial involves writing code, e.g. for a module or client, the tutorial should include the complete result code within its text. Ideally, it should be possible for a reader to copy and paste all the code blocks in the document into a file, effectively concatentating them together, and wind up with a coherent and runnable program. Sometimes this is not possible, e.g. because C# requires wrapping your whole file in a bunch of scopes. In this case, precede each code block with a sentence that describes where the reader is going to paste it.
344+
If the tutorial involves writing code, e.g. for a module or client, the tutorial should include the complete result code within its text. Ideally, it should be possible for a reader to copy and paste all the code blocks in the document into a file, effectively concatenating them together, and wind up with a coherent and runnable program. Sometimes this is not possible, e.g. because C# requires wrapping your whole file in a bunch of scopes. In this case, precede each code block with a sentence that describes where the reader is going to paste it.
345345
346346
Include even uninteresting code, like imports! You can rush through these without spending too much time on them, but make sure that every line of code required to make the project work appears in the tutorial.
347347

docs/cli-reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ This document contains the help content for the `spacetime` command-line program
5454
* `logout`
5555
* `init` — Initializes a new spacetime project. WARNING: This command is UNSTABLE and subject to breaking changes.
5656
* `build` — Builds a spacetime module.
57-
* `server` — Manage the connection to the SpacetimeDB server. WARNING: This command is UNSTABLE and subject to breaking changes.
57+
* `server` — Manage the connection to the SpacetimeDB database server. WARNING: This command is UNSTABLE and subject to breaking changes.
5858
* `subscribe` — Subscribe to SQL queries on the database. WARNING: This command is UNSTABLE and subject to breaking changes.
5959
* `start` — Start a local SpacetimeDB instance
6060
* `version` — Manage installed spacetime versions
@@ -83,7 +83,7 @@ Run `spacetime help publish` for more detailed information.
8383

8484
###### <b>Options:</b>
8585

86-
* `-c`, `--delete-data` — When publishing to an existing database identity, first DESTROY all data associated with the module
86+
* `-c`, `--delete-data` — When publishing to an existing database identity, first DESTROY all data associated with the database
8787
* `--build-options <BUILD_OPTIONS>` — Options to pass to the build command, for example --build-options='--lint-dir='
8888

8989
Default value: ``
@@ -391,7 +391,7 @@ Builds a spacetime module.
391391

392392
## spacetime server
393393

394-
Manage the connection to the SpacetimeDB server. WARNING: This command is UNSTABLE and subject to breaking changes.
394+
Manage the connection to the SpacetimeDB database server. WARNING: This command is UNSTABLE and subject to breaking changes.
395395

396396
**Usage:** `spacetime server
397397
server <COMMAND>`

docs/deploying/spacetimedb-standalone.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ If you have uncommented the `/v1/publish` restriction in Step 3 then you won't b
168168
```bash
169169
spacetime build
170170
scp target/wasm32-unknown-unknown/release/spacetime_module.wasm ubuntu@<host>:/home/ubuntu/
171-
ssh ubuntu@<host> spacetime publish -s local --bin-path spacetime_module.wasm <module-name>
171+
ssh ubuntu@<host> spacetime publish -s local --bin-path spacetime_module.wasm <database-name>
172172
```
173173

174174
You could put the above commands into a shell script to make publishing to your server easier and faster. It's also possible to integrate a script like this into Github Actions to publish on some event (like a PR merging into master).

docs/http/database.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Accessible through the CLI as `spacetime delete <identity>`.
127127

128128
## `GET /v1/database/:name_or_identity/names`
129129

130-
Get the names this datbase can be identified by.
130+
Get the names this database can be identified by.
131131

132132
#### Returns
133133

docs/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Clients are regular software applications that developers can choose how to depl
229229

230230
### Identity
231231

232-
A SpacetimeDB `Identity` identifies someone interacting with a module. It is a long lived, public, globally valid identifier that will always refer to the same end user, even across different connections.
232+
A SpacetimeDB `Identity` identifies someone interacting with a database. It is a long lived, public, globally valid identifier that will always refer to the same end user, even across different connections.
233233

234234
A user's `Identity` is attached to every [reducer call](#reducer) they make, and you can use this to decide what they are allowed to do.
235235

@@ -261,9 +261,9 @@ def identity_from_claims(issuer: str, subject: str) -> [u8; 32]:
261261

262262
### ConnectionId
263263

264-
A `ConnectionId` identifies client connections to a SpacetimeDB module.
264+
A `ConnectionId` identifies client connections to a SpacetimeDB database.
265265

266-
A user has a single [`Identity`](#identity), but may open multiple connections to your module. Each of these will receive a unique `ConnectionId`.
266+
A user has a single [`Identity`](#identity), but may open multiple connections to your database. Each of these will receive a unique `ConnectionId`.
267267

268268
### Energy
269269
**Energy** is the currency used to pay for data storage and compute operations in a SpacetimeDB host.

docs/modules/c-sharp/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,13 +841,13 @@ This reducer can be used to configure any static data tables used by your module
841841

842842
### The `ClientConnected` reducer
843843

844-
This reducer is marked with `[SpacetimeDB.Reducer(ReducerKind.ClientConnected)]`. It is run when a client connects to the SpacetimeDB module. Their identity can be found in the sender value of the `ReducerContext`.
844+
This reducer is marked with `[SpacetimeDB.Reducer(ReducerKind.ClientConnected)]`. It is run when a client connects to the SpacetimeDB database. Their identity can be found in the sender value of the `ReducerContext`.
845845

846846
If an error occurs in the reducer, the client will be disconnected.
847847

848848
### The `ClientDisconnected` reducer
849849

850-
This reducer is marked with `[SpacetimeDB.Reducer(ReducerKind.ClientDisconnected)]`. It is run when a client disconnects from the SpacetimeDB module. Their identity can be found in the sender value of the `ReducerContext`.
850+
This reducer is marked with `[SpacetimeDB.Reducer(ReducerKind.ClientDisconnected)]`. It is run when a client disconnects from the SpacetimeDB database. Their identity can be found in the sender value of the `ReducerContext`.
851851

852852
If an error occurs in the disconnect reducer, the client is still recorded as disconnected.
853853

@@ -1013,7 +1013,7 @@ namespace SpacetimeDB
10131013

10141014
Methods for writing to a private debug log. Log messages will include file and line numbers.
10151015

1016-
Log outputs of a running module can be inspected using the `spacetime logs` command:
1016+
Log outputs of a running database can be inspected using the `spacetime logs` command:
10171017

10181018
```text
10191019
spacetime logs <DATABASE_IDENTITY>

docs/modules/c-sharp/quickstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public static void ClientConnected(ReducerContext ctx)
233233
}
234234
```
235235

236-
Similarly, whenever a client disconnects, the module will execute the `OnDisconnect` event if it's registered with `ReducerKind.ClientDisconnected`. We'll use it to un-set the `Online` status of the `User` for the disconnected client.
236+
Similarly, whenever a client disconnects, the database will execute the `OnDisconnect` event if it's registered with `ReducerKind.ClientDisconnected`. We'll use it to un-set the `Online` status of the `User` for the disconnected client.
237237

238238
Add the following code after the `OnConnect` handler:
239239

@@ -311,6 +311,6 @@ spacetime sql quickstart-chat "SELECT * FROM message"
311311

312312
You've just set up your first database in SpacetimeDB! You can find the full code for this client [in the C# server module example](https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk/tree/master/examples~/quickstart-chat/server).
313313

314-
The next step would be to create a client module that interacts with this module. You can use any of SpacetimDB's supported client languages to do this. Take a look at the quick start guide for your client language of choice: [Rust](/docs/sdks/rust/quickstart), [C#](/docs/sdks/c-sharp/quickstart), or [TypeScript](/docs/sdks/typescript/quickstart).
314+
The next step would be to create a client that interacts with this module. You can use any of SpacetimDB's supported client languages to do this. Take a look at the quick start guide for your client language of choice: [Rust](/docs/sdks/rust/quickstart), [C#](/docs/sdks/c-sharp/quickstart), or [TypeScript](/docs/sdks/typescript/quickstart).
315315

316316
If you are planning to use SpacetimeDB with the Unity game engine, you can skip right to the [Unity Comprehensive Tutorial](/docs/unity/part-1).

docs/modules/rust/quickstart.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,15 @@ You could extend the validation in `validate_message` in similar ways to `valida
182182

183183
## Set users' online status
184184

185-
Whenever a client connects, the module will run a special reducer, annotated with `#[reducer(client_connected)]`, if it's defined. By convention, it's named `client_connected`. We'll use it to create a `User` record for the client if it doesn't yet exist, and to set its online status.
185+
Whenever a client connects, the database will run a special reducer, annotated with `#[reducer(client_connected)]`, if it's defined. By convention, it's named `client_connected`. We'll use it to create a `User` record for the client if it doesn't yet exist, and to set its online status.
186186

187187
We'll use `ctx.db.user().identity().find(ctx.sender)` to look up a `User` row for `ctx.sender`, if one exists. If we find one, we'll use `ctx.db.user().identity().update(..)` to overwrite it with a row that has `online: true`. If not, we'll use `ctx.db.user().insert(..)` to insert a new row for our new user. All three of these methods are generated by the `#[table(..)]` macro, with rows and behavior based on the row attributes. `ctx.db.user().find(..)` returns an `Option<User>`, because of the unique constraint from the `#[primary_key]` attribute. This means there will be either zero or one matching rows. If we used `try_insert` here it would return a `Result<(), UniqueConstraintViolation>` because of the same unique constraint. However, because we're already checking if there is a user with the given sender identity we know that inserting into this table will not fail. Therefore, we use `insert`, which automatically unwraps the result, simplifying the code. If we want to overwrite a `User` row, we need to do so explicitly using `ctx.db.user().identity().update(..)`.
188188

189189
To `server/src/lib.rs`, add the definition of the connect reducer:
190190

191191
```rust
192192
#[reducer(client_connected)]
193-
// Called when a client connects to the SpacetimeDB
193+
// Called when a client connects to a SpacetimeDB database server
194194
pub fn client_connected(ctx: &ReducerContext) {
195195
if let Some(user) = ctx.db.user().identity().find(ctx.sender) {
196196
// If this is a returning user, i.e. we already have a `User` with this `Identity`,
@@ -208,11 +208,11 @@ pub fn client_connected(ctx: &ReducerContext) {
208208
}
209209
```
210210

211-
Similarly, whenever a client disconnects, the module will run the `#[reducer(client_disconnected)]` reducer if it's defined. By convention, it's named `client_disconnected`. We'll use it to un-set the `online` status of the `User` for the disconnected client.
211+
Similarly, whenever a client disconnects, the database will run the `#[reducer(client_disconnected)]` reducer if it's defined. By convention, it's named `client_disconnected`. We'll use it to un-set the `online` status of the `User` for the disconnected client.
212212

213213
```rust
214214
#[reducer(client_disconnected)]
215-
// Called when a client disconnects from SpacetimeDB
215+
// Called when a client disconnects from SpacetimeDB database server
216216
pub fn identity_disconnected(ctx: &ReducerContext) {
217217
if let Some(user) = ctx.db.user().identity().find(ctx.sender) {
218218
ctx.db.user().identity().update(User { online: false, ..user });
@@ -275,6 +275,6 @@ spacetime sql quickstart-chat "SELECT * FROM message"
275275

276276
You can find the full code for this module [in the SpacetimeDB module examples](https://github.com/clockworklabs/SpacetimeDB/tree/master/modules/quickstart-chat).
277277

278-
You've just set up your first database in SpacetimeDB! The next step would be to create a client module that interacts with this module. You can use any of SpacetimDB's supported client languages to do this. Take a look at the quickstart guide for your client language of choice: [Rust](/docs/sdks/rust/quickstart), [C#](/docs/sdks/c-sharp/quickstart), or [TypeScript](/docs/sdks/typescript/quickstart).
278+
You've just set up your first database in SpacetimeDB! The next step would be to create a client that interacts with this module. You can use any of SpacetimDB's supported client languages to do this. Take a look at the quickstart guide for your client language of choice: [Rust](/docs/sdks/rust/quickstart), [C#](/docs/sdks/c-sharp/quickstart), or [TypeScript](/docs/sdks/typescript/quickstart).
279279

280280
If you are planning to use SpacetimeDB with the Unity game engine, you can skip right to the [Unity Comprehensive Tutorial](/docs/unity/part-1).

0 commit comments

Comments
 (0)