You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: stop.rs
    path of file: ./repos/rivet/svc/pkg/job-run/worker/src/workers
    
    the code of the file until where you have to start completion: use chirp_worker::prelude::*;
use proto::backend::pkg::*;

lazy_static::lazy_static! {
	static ref NOMAD_CONFIG: nomad_client::apis::configuration::Configuration =
		nomad_util::config_from_env().unwrap();
}

#[derive(Debug, sqlx::FromRow)]
struct RunRow {
	region_id: Uuid,
	create_ts: i64,
	stop_ts: Option<i64>,
}

#[derive(Debug, sqlx::FromRow)]
struct RunMetaNomadRow {
	dispatched_job_id: Option<String>,
}

#[worker(name = "job-run-stop")]
async fn worker(ctx: &OperationContext<job_run::msg::stop::Message>) -> GlobalResult<()> {
	// NOTE: Idempotent

	let run_id = unwrap_ref!(ctx.run_id).as_uuid();

	// Cleanup the job ASAP.
	//
	// This will also be called in `job-run-cleanup`, but this is idempotent.
	msg!([ctx] job_run::msg::cleanup(run_id) {
		run_id: Some(run_id.into())
    
async fn worker(ctx: &OperationContext<job_run::msg::stop::Message>) -> GlobalResult<()> {
	// NOTE: Idempotent

	let run_id = unwrap_ref!(ctx.run_id).as_uuid();

	// Cleanup the job ASAP.
	//
	// This will also be called in `job-run-cleanup`, but this is idempotent.
	msg!([ctx] job_run::msg::cleanup(run_id) {
		run_id: Some(run_id.into()),
		..Default::default()
	})
	.await?;

	let Some((run_row, run_meta_nomad_row)) =
		rivet_pools::utils::crdb::tx(&ctx.crdb().await?, |tx| {
			Box::pin(update_db(ctx.clone(), ctx.ts(), run_id, tx))
		})
		.await?
	else {
		if ctx.req_dt() > util::duration::minutes(5) {
			tracing::error!("discarding stale message");
			return Ok(());
		} else {
			retry_bail!("run not found, may be race condition with insertion");
		}
	};

	// Get the region
	let region_res = op!([ctx] region_get {
		region_ids: vec![run_row.region_id.into()],
	})
	.await?;
	let region = unwrap!(region_res.regions.first());

	// TODO: Handle 404 safely. See RIV-179
	// Stop the job.
	//
	// Setting purge to false will change the behavior of the create poll
	// functionality if the job dies immediately. You can set it to false to
	// debug lobbies, but it's preferred to extract metadata from the
	// job-run-stop lifecycle event.
	if let Some(dispatched_job_id) = &run_meta_nomad_row
		.as_ref()
		.and_then(|x| x.dispatched_job_id.as_ref())
	{
		match nomad_client::apis::jobs_api::stop_job(
			&NOMAD_CONFIG,
			dispatched_job_id,
			None,
			Some(&region.nomad_region),
			None,
			None,
			Some(false), // TODO: Maybe change back to true for performance?
		)
		.await
		{
			Ok(_) => tracing::info!("job stopped"),
			Err(err) => {
				tracing::warn!(?err, "error thrown while stopping job, probably a 404, will continue as if stopped normally");
			}
		}
	}

	Ok(())
}