mirror of
https://github.com/gmbrax/MediaManager-core.git
synced 2026-11-09 14:00:17 +00:00
Compare commits
12
Commits
develop
...
e729ffcd41
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e729ffcd41 | ||
|
|
c6111980f5 | ||
|
|
01364bdc16 | ||
|
|
64d6f80267 | ||
|
|
78f8e08bb9 | ||
|
|
a0bf000edc | ||
|
|
8e80b3c74e | ||
|
|
37b76d17f4 | ||
|
|
8211506360 | ||
|
|
41a2b97122 | ||
|
|
4f3ee4ed74 | ||
|
|
281618a725 |
@@ -0,0 +1,57 @@
|
||||
name: Qodana
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
target_ref:
|
||||
description: 'Branch, tag, or commit SHA to analyze (default: develop)'
|
||||
required: false
|
||||
default: 'develop'
|
||||
type: string
|
||||
pull_request:
|
||||
push:
|
||||
branches: # Specify your branches here
|
||||
- master
|
||||
- main # The 'main' branch
|
||||
- develop
|
||||
- 'releases/*' # The release branches
|
||||
|
||||
jobs:
|
||||
qodana:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
checks: write
|
||||
steps:
|
||||
# Checkout for pull_request events: use the PR head SHA for accurate analysis
|
||||
- name: Checkout (pull_request)
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0 # a full history is required for pull request analysis
|
||||
|
||||
# Checkout for manual runs: use the selected branch/ref (default: develop)
|
||||
- name: Checkout (workflow_dispatch)
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.target_ref }}
|
||||
fetch-depth: 0
|
||||
|
||||
# Checkout for push events (e.g., merges to develop): use the current commit
|
||||
- name: Checkout (push)
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: 'Qodana Scan'
|
||||
uses: JetBrains/qodana-action@v2025.2
|
||||
with:
|
||||
# Enable PR-specific reporting only for pull_request events
|
||||
pr-mode: ${{ github.event_name == 'pull_request' }}
|
||||
# Pass the linter image via args (the action does not support an `image` input)
|
||||
args: --image jetbrains/qodana-jvm:2025.2
|
||||
env:
|
||||
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN_268690425 }}
|
||||
QODANA_ENDPOINT: 'https://qodana.cloud'
|
||||
@@ -0,0 +1,5 @@
|
||||
# Contributor Code of Conduct
|
||||
|
||||
This project adheres to No Code of Conduct. We are all adults. We accept anyone's contributions. Nothing else matters.
|
||||
|
||||
For more information please visit the [No Code of Conduct](https://nocodeofconduct.com) homepage.
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
# Refactoring History—MediaManager Core
|
||||
|
||||
This document records the refactorings applied during development.
|
||||
|
||||
## Refactoring #1: Connection Pool Implementation
|
||||
|
||||
**Date**: 2025-11-13
|
||||
**Commits**: ```22476abb27d95e88ae0439d97ef97467b6a4f985```
|
||||
|
||||
### Problem Identified
|
||||
- Database connections were created multiple times
|
||||
- No centralized control
|
||||
- Possible resource leaks
|
||||
|
||||
### Technique Applied
|
||||
- **Pattern**: Singleton Pattern
|
||||
- **Refactoring**: Extract Class + Introduce Singleton
|
||||
|
||||
### Solution
|
||||
Created `DatabaseManager` class that:
|
||||
- Maintains single instance (Singleton)
|
||||
- Manages connection pool
|
||||
- Provides centralized `getConnection()` method
|
||||
|
||||
### Result
|
||||
- ✅ Single reusable connection
|
||||
- ✅ Code centralized in one class
|
||||
- ✅ Thread-safe
|
||||
- ✅ Easier to test
|
||||
|
||||
### Extracted Component
|
||||
`DatabaseManager` - available in `mediamanager-components`
|
||||
|
||||
---
|
||||
|
||||
## Refactoring #2: Thread Pool for IPC
|
||||
|
||||
**Date**: 2025-11-14
|
||||
**Commits**: ```f1071dca03da33f7355a6927497509b5aedaa4a2```
|
||||
|
||||
### Problem Identified
|
||||
- New thread created for each IPC client
|
||||
- Doesn't scale well
|
||||
- Thread creation overhead
|
||||
|
||||
### Technique Applied
|
||||
- **Pattern**: Thread Pool Pattern
|
||||
- **Refactoring**: Replace Thread Creation with Thread Pool
|
||||
|
||||
### Solution
|
||||
Implemented `ExecutorService` with:
|
||||
- Fixed thread pool
|
||||
- Thread reuse
|
||||
- Ordered shutdown
|
||||
|
||||
### Result
|
||||
- ✅ Better performance
|
||||
- ✅ Controlled resource usage
|
||||
- ✅ Scalability
|
||||
|
||||
### Extracted Component
|
||||
`IPCServer` - available in `mediamanager-components`
|
||||
|
||||
---
|
||||
|
||||
## Refactoring #3: Graceful Shutdown
|
||||
|
||||
**Date**: 2025-11-13
|
||||
**Commits**: ```65e14930076db71a312feae373d6c5daee3c4d29```,```b7ff9d1e16c85bf986a770676827bee390f0d53c```
|
||||
|
||||
### Problem Identified
|
||||
- Resources weren't released on exit
|
||||
- Database connections remained open
|
||||
- Thread pool didn't terminate correctly
|
||||
|
||||
### Technique Applied
|
||||
- **Pattern**: Shutdown Hook Pattern
|
||||
- **Refactoring**: Introduce Shutdown Protocol
|
||||
|
||||
### Solution
|
||||
Implemented shutdown hooks that:
|
||||
- Close database connections
|
||||
- Terminate thread pools
|
||||
- Release sockets
|
||||
- In specific order with timeouts
|
||||
|
||||
### Result
|
||||
- ✅ Ordered cleanup
|
||||
- ✅ No resource leaks
|
||||
- ✅ Shutdown logging
|
||||
- ✅ Timeout to prevent hanging
|
||||
|
||||
### Extracted Component
|
||||
Logic incorporated in `DatabaseManager` and `IPCServer`
|
||||
|
||||
---
|
||||
|
||||
## Applied Principles
|
||||
|
||||
- **DRY** (Don't Repeat Yourself): Elimination of duplicated code
|
||||
- **SOLID**: Especially Single Responsibility Principle
|
||||
- **Design Patterns**: Singleton, Thread Pool, Shutdown Hook
|
||||
- **Clean Code**: Clear names, small methods, well-defined responsibilities
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
####################################################################################################################
|
||||
# WARNING: Do not store sensitive information in this file, as its contents will be included in the Qodana report. #
|
||||
####################################################################################################################
|
||||
|
||||
version: "1.0"
|
||||
linter: jetbrains/qodana-jvm:2025.2
|
||||
profile:
|
||||
name: qodana.recommended
|
||||
bootstrap: |
|
||||
# Generate sources (including protobuf) so Qodana resolves imports correctly
|
||||
# Prefer Maven Wrapper if present; fall back to system mvn (POSIX sh compatible)
|
||||
# Ensure mvnw is executable if present
|
||||
if [ -f ./mvnw ]; then chmod +x ./mvnw || true; fi
|
||||
if [ -x ./mvnw ]; then
|
||||
./mvnw -B -q -DskipTests -DskipITs=true generate-sources || true
|
||||
elif [ -f ./mvnw ]; then
|
||||
sh ./mvnw -B -q -DskipTests -DskipITs=true generate-sources || true
|
||||
elif command -v mvn >/dev/null 2>&1; then
|
||||
mvn -B -q -DskipTests -DskipITs=true generate-sources || true
|
||||
else
|
||||
echo "[Qodana bootstrap] Maven not available; skipping source generation"
|
||||
fi
|
||||
include:
|
||||
- name: CheckDependencyLicenses
|
||||
exclude:
|
||||
# Exclude generated sources from inspections to reduce noise
|
||||
- name: All
|
||||
paths:
|
||||
- target/generated-sources/**
|
||||
- target/protoc-dependencies/**
|
||||
Reference in New Issue
Block a user