-
Notifications
You must be signed in to change notification settings - Fork 10
tweak(cmd): only enable clickhouse with ENV #139
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
Conversation
There was a problem hiding this 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 adds conditional initialization of ClickHouse based on environment configuration, allowing the service to run without ClickHouse when not configured.
- Introduces an
Enabledflag to the ClickHouse client to track initialization state - Adds a helper function to determine whether ClickHouse should be initialized based on configuration
- Fixes MIME type validation to use a fixed buffer size instead of full file size
- Corrects a spelling error in an error message
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/clickhouse/client.go | Adds Enabled field and conditional initialization logic to skip ClickHouse when disabled |
| cmd/lite/lite.go | Implements conditional ClickHouse initialization based on host configuration |
| internal/http/middleware/mime.go | Changes buffer allocation from file size to fixed 3072 bytes and fixes spelling error |
| internal/http/httputil/mime.go | Updates buffer allocation to use fixed size instead of file header size |
| internal/service/file/file_service.go | Adds comments clarifying API usage context for methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| c := &Client{} | ||
| func NewClient(config *Config, enabled bool) *Client { | ||
| if !enabled { | ||
| slog.Warn("clickhosue is disabled, logging is not available") |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'clickhosue' to 'clickhouse'.
| slog.Warn("clickhosue is disabled, logging is not available") | |
| slog.Warn("clickhouse is disabled, logging is not available") |
cmd/lite/lite.go
Outdated
| if clickhouseHost != "" { | ||
| return true | ||
| } | ||
| return false | ||
| } | ||
|
|
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function can be simplified to a single return statement: return clickhouseHost != \"\"
| if clickhouseHost != "" { | |
| return true | |
| } | |
| return false | |
| } | |
| return clickhouseHost != "" | |
| } |
cmd/lite/lite.go
Outdated
| clickhouse.AutoMigrate(cmd.Context(), chConfig) | ||
| } | ||
|
|
||
| clickhouseClient := clickhouse.NewClient(chConfig, shouldInitClickhouse(chConfig.Host)) |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shouldInitClickhouse function is called twice with the same argument (lines 83 and 88). Consider storing the result from line 83 in the clickhouseEnabled variable and reusing it here.
| clickhouseClient := clickhouse.NewClient(chConfig, shouldInitClickhouse(chConfig.Host)) | |
| clickhouseClient := clickhouse.NewClient(chConfig, clickhouseEnabled) |
30fa3e5 to
f110099
Compare
No description provided.