Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pb, ds): move to edge #1942

Draft
wants to merge 2 commits into
base: 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker
Choose a base branch
from

Conversation

MasterPtato
Copy link
Contributor

Changes

Copy link

cloudflare-workers-and-pages bot commented Jan 25, 2025

Deploying rivet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1162ce3
Status: ✅  Deploy successful!
Preview URL: https://5440b11e.rivet.pages.dev
Branch Preview URL: https://01-25-feat-pb-ds--move-to-ed.rivet.pages.dev

View logs

Copy link
Contributor Author

MasterPtato commented Jan 25, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR moves pegboard and ds services to the edge infrastructure, introducing new workflow handling capabilities and SQLite database integration.

  • Added new edge-monolith-workflow-worker in /packages/services/edge/monolith/standalone/workflow-worker/ with concerning error handling that unconditionally bails on worker exit
  • Empty test table migrations in /packages/services/edge/pegboard/src/workflows/actor/migrations.rs and /packages/services/edge/pegboard/src/workflows/client/migrations.rs need proper schema definitions
  • Added SQLite database access in ActivityCtx and Connection for per-workflow state storage with workflow-specific database names
  • Implemented comprehensive client workflow in /packages/services/edge/pegboard/src/workflows/client/mod.rs for handling registration, events, and actor management
  • New feature flag system in /packages/services/edge/pegboard/Cargo.toml organizes dependencies into tiers (default, workflows, chirp)

12 file(s) reviewed, 16 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 15 to 16
ds.workspace = true
pegboard.workspace = true
Copy link

Choose a reason for hiding this comment

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

logic: ds and pegboard dependencies should specify features needed for workflow integration, e.g. pegboard = { workspace = true, features = ["workflows"] }

Comment on lines 8 to 13
[dependencies]
chirp-workflow.workspace = true
rivet-config.workspace = true
rivet-health-checks.workspace = true
rivet-metrics.workspace = true
rivet-runtime.workspace = true
Copy link

Choose a reason for hiding this comment

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

style: consider adding tokio with appropriate runtime features since this is a worker service that will likely need async functionality


// Start worker
worker.wake_start(config, pools).await?;
bail!("worker exited unexpectedly");
Copy link

Choose a reason for hiding this comment

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

logic: unconditional bail! means worker will always exit with error, even for graceful shutdowns - should check exit condition first

let reg = ds::registry()?
.merge(pegboard::registry()?)?;

let db = db::DatabaseFdbSqliteNats::from_pools(pools.clone())?;
Copy link

Choose a reason for hiding this comment

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

style: pools is cloned here but original pools object is passed to wake_start - consider reusing the cloned pools

Comment on lines 10 to 11
workflows = ["chirp"]
chirp = ["chirp-workflow", "sqlx", "nix", "server-spec"]
Copy link

Choose a reason for hiding this comment

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

logic: workflows feature depends on chirp but chirp is not listed as a dependency in the feature definition - should be workflows = ["chirp-workflow"] or include both

sql_execute!(
[ctx, pool]
"
CREATE TABLE test (
Copy link

Choose a reason for hiding this comment

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

style: 'test' appears to be a placeholder name. Use a descriptive table name that reflects its purpose in production.

Comment on lines 1 to 2
pub mod client;
pub mod actor;
Copy link

Choose a reason for hiding this comment

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

style: module order should be alphabetical - 'actor' should come before 'client'

Comment on lines 235 to 234
// TODO(RVT-4450): `last_event_idx < $2` and `ON CONFLICT DO NOTHING` is a workaround
let inserted_rows = sql_fetch_all!(
Copy link

Choose a reason for hiding this comment

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

logic: The workaround for RVT-4450 using last_event_idx &lt; $2 and ON CONFLICT DO NOTHING could potentially miss events if they arrive out of order. Consider adding additional validation or logging.

Comment on lines 446 to 458
// TODO: Send as a single message
for (i, raw_command) in raw_commands.into_iter().enumerate() {
let wrapped_command = protocol::CommandWrapper {
index: index + i as i64,
inner: raw_command,
};

// Forward signal to ws as message
ctx.msg(ToWs {
client_id,
inner: protocol::ToClient::Commands(vec![wrapped_command]),
})
.send()
.await?;
}
Copy link

Choose a reason for hiding this comment

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

style: Sending commands individually could cause performance issues with high command volumes. Consider implementing the TODO to batch commands into a single message.

Comment on lines 472 to 471
if matches!(signal.try_into()?, Signal::SIGTERM | Signal::SIGKILL) {
let res = ctx
Copy link

Choose a reason for hiding this comment

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

logic: The signal type check should handle conversion errors from try_into() more explicitly to avoid potential panics

@MasterPtato MasterPtato force-pushed the 01-25-feat_pb_ds__move_to_edge branch from 1023d01 to 9f75ea9 Compare January 27, 2025 22:18
@MasterPtato MasterPtato changed the base branch from 01-25-chore_restructure_server_binaries to 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker January 27, 2025 22:18
@MasterPtato MasterPtato force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from df8b94d to f6f8a7b Compare January 28, 2025 01:43
@MasterPtato MasterPtato force-pushed the 01-25-feat_pb_ds__move_to_edge branch from 9f75ea9 to 176d520 Compare January 28, 2025 01:43
Copy link

cloudflare-workers-and-pages bot commented Jan 28, 2025

Deploying rivet-hub with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1162ce3
Status: ✅  Deploy successful!
Preview URL: https://5c8bac11.rivet-hub-7jb.pages.dev
Branch Preview URL: https://01-25-feat-pb-ds--move-to-ed.rivet-hub-7jb.pages.dev

View logs

@MasterPtato MasterPtato force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from f6f8a7b to d7a614b Compare February 1, 2025 02:41
@MasterPtato MasterPtato force-pushed the 01-25-feat_pb_ds__move_to_edge branch from 0ce8234 to f532f05 Compare February 1, 2025 02:41
@MasterPtato MasterPtato force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from d7a614b to cbfb3c8 Compare February 1, 2025 02:44
@MasterPtato MasterPtato force-pushed the 01-25-feat_pb_ds__move_to_edge branch from f532f05 to 0a58d12 Compare February 1, 2025 02:44
@MasterPtato MasterPtato force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from cbfb3c8 to f993bd7 Compare February 3, 2025 19:19
@MasterPtato MasterPtato force-pushed the 01-25-feat_pb_ds__move_to_edge branch from 0a58d12 to ba14c9f Compare February 3, 2025 19:19
@MasterPtato MasterPtato force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from f993bd7 to ca16fe8 Compare February 4, 2025 00:47
@MasterPtato MasterPtato force-pushed the 01-25-feat_pb_ds__move_to_edge branch 2 times, most recently from e057146 to 5e1789e Compare February 4, 2025 01:58
@MasterPtato MasterPtato force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from ca16fe8 to e8b385a Compare February 4, 2025 22:32
@MasterPtato MasterPtato force-pushed the 01-25-feat_pb_ds__move_to_edge branch from 5e1789e to dfa1115 Compare February 4, 2025 22:32
@MasterPtato MasterPtato force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from e8b385a to 962e10c Compare February 5, 2025 01:42
@MasterPtato MasterPtato force-pushed the 01-25-feat_pb_ds__move_to_edge branch from dfa1115 to 1162ce3 Compare February 5, 2025 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant