Skip to content

Commit

Permalink
replace listen example with a small chat example
Browse files Browse the repository at this point in the history
Co-authored-by: Stephen <webmaster@scd31.com>
  • Loading branch information
JockeM and Stephen committed Jul 9, 2023
1 parent f06c4c2 commit 0553981
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 162 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ jobs:
command: test
args: -p sqlx-example-postgres-axum-social

- name: Chat (Setup)
working-directory: examples/postgres/chat
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/chat
run: sqlx db create

- name: Chat (Run)
uses: actions-rs/cargo@v1
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/chat
with:
command: run
args: -p sqlx-example-postgres-chat

- name: Files (Setup)
working-directory: examples/postgres/files
env:
Expand Down Expand Up @@ -181,20 +195,6 @@ jobs:
command: run
args: -p sqlx-example-postgres-json

- name: Listen (Setup)
working-directory: examples/postgres/listen
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/listen
run: sqlx db create

- name: Listen (Run)
uses: actions-rs/cargo@v1
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/listen
with:
command: run
args: -p sqlx-example-postgres-listen

- name: Mockable TODOs (Setup)
working-directory: examples/postgres/mockable-todos
env:
Expand Down
86 changes: 77 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ members = [
"examples/postgres/axum-social-with-tests",
"examples/postgres/files",
"examples/postgres/json",
"examples/postgres/listen",
"examples/postgres/chat",
"examples/postgres/todos",
"examples/postgres/mockable-todos",
"examples/postgres/transaction",
Expand Down
13 changes: 13 additions & 0 deletions examples/postgres/chat/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "sqlx-example-postgres-chat"
version = "0.1.0"
edition = "2021"
workspace = "../../../"

[dependencies]
sqlx = { path = "../../../", features = [ "postgres", "runtime-tokio-native-tls" ] }
futures = "0.3.1"
tokio = { version = "1.20.0", features = [ "rt-multi-thread", "macros" ] }
tui = "0.19.0"
crossterm = "0.25"
unicode-width = "0.1"
21 changes: 21 additions & 0 deletions examples/postgres/chat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Chat Example

## Description

This example demonstrates how to use PostgreSQL channels to create a very simple chat application.

## Setup

1. Declare the database URL

```
export DATABASE_URL="postgres://postgres:password@localhost/files"
```

## Usage

Run the project

```
cargo run -p sqlx-examples-postgres-chat
```

0 comments on commit 0553981

Please sign in to comment.