Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 23 additions & 96 deletions Cargo.lock

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

11 changes: 6 additions & 5 deletions crates/devolutions-pedm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ anyhow = "1.0"
axum = { version = "0.8", default-features = false, features = ["http1", "json", "tokio", "query", "tracing", "tower-log", "form", "original-uri", "matched-path"] }
base16ct = { version = "0.2", features = ["std", "alloc"] }
base64 = "0.22"
chrono = { version = "0.4", features = ["serde"] }
digest = "0.10"
hyper = { version = "1.3", features = ["server"] }
hyper-util = { version = "0.1", features = ["tokio"] }
schemars = "0.8"
schemars = { version = "0.8", features = ["chrono"] }
serde = "1.0"
serde_json = "1.0"
sha1 = "0.10"
Expand All @@ -39,10 +40,10 @@ uuid = "1"
dunce = "1.0"
tower = "0.5"
futures-util = "0.3"
libsql = { version = "0.9", optional = true, features = [ "core", "stream"] }
tokio-postgres = { version = "0.7", optional = true }
bb8 = { version = "0.9.0", optional = true }
bb8-postgres = { version = "0.9.0", optional = true }
libsql = { version = "0.9", optional = true, default-features = false, features = [ "core", "sync"] }
tokio-postgres = { version = "0.7", optional = true, features = ["with-chrono-0_4"] }
bb8 = { version = "0.9", optional = true }
bb8-postgres = { version = "0.9", optional = true }

[features]
default = ["libsql"]
Expand Down
47 changes: 33 additions & 14 deletions crates/devolutions-pedm/schema/libsql.sql
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is there some rationale for when the pedm prefix is used in table names?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was in case the database is also used by Gateway or other programs in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. The table naming is inconsistent. And I can't see other programs using this specific http_request table.

Tables are renamed in 72bae7b. The database is meant for isolated PEDM usage. This is expressed in the example config, with a database name of pedm or file of pedm.sqlite.

Copy link
Copy Markdown
Member

@CBenoit Benoît Cortier (CBenoit) Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it’s better to use a different database completely! 🙂
I agree with the way you renamed the tables!

Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
/* In SQLite, we store time as integer with microsecond precision. This is the same precision used by TIMESTAMPTZ in Postgres. */
/* In SQLite, we store time as an 8-byte integer (i64) with microsecond precision. This matches TIMESTAMPTZ in Postgres.
Use `chrono::DateTime::timestamp_micros` when inserting or fetching timestamps in Rust.
*/

CREATE TABLE pedm_run (
id INTEGER PRIMARY KEY AUTOINCREMENT,
start_time INTEGER NOT NULL DEFAULT (CAST(strftime('%f', 'now') * 1000000 AS INTEGER)),
pipe_name TEXT NOT NULL
CREATE TABLE IF NOT EXISTS version
(
version integer PRIMARY KEY,
updated_at integer NOT NULL DEFAULT (
CAST(strftime('%s', 'now') AS integer) * 1000000 + CAST(strftime('%f', 'now') * 1000000 AS integer) % 1000000
)
);

CREATE TABLE http_request (
id INTEGER PRIMARY KEY,
at INTEGER NOT NULL DEFAULT (CAST(strftime('%f', 'now') * 1000000 AS INTEGER)),
method TEXT NOT NULL,
path TEXT NOT NULL,
status_code INTEGER NOT NULL
CREATE TABLE IF NOT EXISTS run
(
id integer PRIMARY KEY AUTOINCREMENT,
start_time integer NOT NULL DEFAULT (
CAST(strftime('%s', 'now') AS integer) * 1000000 + CAST(strftime('%f', 'now') * 1000000 AS integer) % 1000000
),
pipe_name text NOT NULL
);

CREATE TABLE elevate_tmp_request (
req_id INTEGER PRIMARY KEY,
seconds INTEGER NOT NULL
CREATE TABLE IF NOT EXISTS http_request
(
id integer PRIMARY KEY,
at integer NOT NULL DEFAULT (
CAST(strftime('%s', 'now') AS integer) * 1000000 + CAST(strftime('%f', 'now') * 1000000 AS integer) % 1000000
),
method text NOT NULL,
path text NOT NULL,
status_code integer NOT NULL
);

CREATE TABLE IF NOT EXISTS elevate_tmp_request
(
req_id integer PRIMARY KEY,
seconds integer NOT NULL
);

INSERT INTO version (version) VALUES (0) ON CONFLICT DO NOTHING;
Loading