Skip to content

refactor appState and proxy#257

Closed
ChuckHend wants to merge 10 commits intomainfrom
appstate
Closed

refactor appState and proxy#257
ChuckHend wants to merge 10 commits intomainfrom
appstate

Conversation

@ChuckHend
Copy link
Copy Markdown
Owner

  • separate the proxy logic from server
  • move cache update process into its own module
  • creates appState struct

@ChuckHend ChuckHend requested a review from Copilot October 11, 2025 15:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the application architecture by consolidating state management into a single AppState struct and separating proxy logic from the main server module.

  • Creates a centralized AppState struct to manage database pools, job cache, worker health, and configuration
  • Extracts cache management functionality into a dedicated cache module
  • Moves PostgreSQL proxy startup logic from main server to the proxy crate

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
server/src/app_state.rs New centralized application state management struct
server/src/cache.rs Extracted cache synchronization and job notification logic
server/src/main.rs Simplified main function using new AppState pattern
server/src/routes/*.rs Updated route handlers to use AppState instead of individual dependencies
proxy/src/proxy.rs Added proxy startup function moved from server main
*/Cargo.toml Updated tracing dependencies to use workspace versions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread server/src/app_state.rs Outdated
Comment thread proxy/src/proxy.rs

let url = Url::parse(&database_url)?;
let postgres_host = url.host_str().unwrap();
let postgres_port = url.port().unwrap();
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

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

Using unwrap() on URL parsing results can cause panics. Consider using proper error handling with meaningful error messages for when host or port are missing from the URL.

Suggested change
let postgres_port = url.port().unwrap();
let postgres_port = url
.port()
.ok_or("Database URL is missing a port")?;

Copilot uses AI. Check for mistakes.
Comment thread server/src/cache.rs
@ChuckHend ChuckHend closed this Oct 11, 2025
@ChuckHend ChuckHend deleted the appstate branch October 11, 2025 18:13
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.

2 participants