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

Open
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: 2c4df8b
Status: ✅  Deploy successful!
Preview URL: https://970b6e7c.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: 2c4df8b
Status: ✅  Deploy successful!
Preview URL: https://64c45ed0.rivet-hub-7jb.pages.dev
Branch Preview URL: https://01-25-feat-pb-ds--move-to-ed.rivet-hub-7jb.pages.dev

View logs

@NathanFlurry NathanFlurry force-pushed the 01-25-feat_pb_ds__move_to_edge branch from 2c4df8b to 592c28d Compare February 20, 2025 02:55
@MasterPtato MasterPtato force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from ebe7baf to 4e622d1 Compare February 20, 2025 22:00
@MasterPtato MasterPtato force-pushed the 01-25-feat_pb_ds__move_to_edge branch from 592c28d to 2c4df8b Compare February 20, 2025 22:00
Copy link

Deploying rivet-hub with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2c4df8b
Status:⚡️  Build in progress...

View logs

Copy link

cloudflare-workers-and-pages bot commented Feb 20, 2025

Deploying rivet-hub with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2c4df8b
Status: ✅  Deploy successful!
Preview URL: https://f2b5364b.rivet-hub-7jb.pages.dev
Branch Preview URL: https://graphite-base-2008.rivet-hub-7jb.pages.dev

View logs

@NathanFlurry NathanFlurry force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from 4e622d1 to ebe7baf Compare February 21, 2025 05:17
@NathanFlurry NathanFlurry force-pushed the 01-25-feat_pb_ds__move_to_edge branch from 2c4df8b to 592c28d Compare February 21, 2025 05:17
Copy link

Deploying rivet-hub with  Cloudflare Pages  Cloudflare Pages

Latest commit: 592c28d
Status: ✅  Deploy successful!
Preview URL: https://1670d0fe.rivet-hub-7jb.pages.dev
Branch Preview URL: https://01-25-feat-pb-ds--move-to-ed.rivet-hub-7jb.pages.dev

View logs

Copy link

Deploying rivet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 592c28d
Status: ✅  Deploy successful!
Preview URL: https://46990fd6.rivet.pages.dev
Branch Preview URL: https://01-25-feat-pb-ds--move-to-ed.rivet.pages.dev

View logs

@MasterPtato MasterPtato force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from ebe7baf to 4e622d1 Compare February 21, 2025 20:04
@MasterPtato MasterPtato force-pushed the 01-25-feat_pb_ds__move_to_edge branch from 592c28d to 2c4df8b Compare February 21, 2025 20:04
Copy link

Deploying rivet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2c4df8b
Status: ✅  Deploy successful!
Preview URL: https://ca29bf81.rivet.pages.dev
Branch Preview URL: https://01-25-feat-pb-ds--move-to-ed.rivet.pages.dev

View logs

@MasterPtato MasterPtato mentioned this pull request Feb 21, 2025
@NathanFlurry NathanFlurry force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from 4e622d1 to ebe7baf Compare February 22, 2025 00:19
@NathanFlurry NathanFlurry force-pushed the 01-25-feat_pb_ds__move_to_edge branch from 2c4df8b to 592c28d Compare February 22, 2025 00:19
@MasterPtato MasterPtato force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from ebe7baf to 4e622d1 Compare February 22, 2025 02:52
@MasterPtato MasterPtato force-pushed the 01-25-feat_pb_ds__move_to_edge branch from 592c28d to 2c4df8b Compare February 22, 2025 02:52
@NathanFlurry NathanFlurry force-pushed the 01-27-chore_workflows_move_wf_gc_and_metrics_publish_into_worker branch from 4e622d1 to ebe7baf Compare February 22, 2025 12:25
@NathanFlurry NathanFlurry force-pushed the 01-25-feat_pb_ds__move_to_edge branch from 2c4df8b to 592c28d Compare February 22, 2025 12:25
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