storage
storage copied to clipboard
feat: Clickhouse Storage Driver
Adding clickhouse implementation, attending #1204 request
Summary by CodeRabbit
-
New Features
- Introduced a Clickhouse storage driver for Go applications, enabling interaction with Clickhouse databases.
- Added configuration options for Clickhouse database connections, including host, port, credentials, and table details.
-
Tests
- Implemented tests for key operations such as setting, getting, and deleting data in Clickhouse.
- Set up GitHub Actions workflows for automated testing of Clickhouse and Cloudflare KV projects.
-
Documentation
- Updated README and configuration files to provide guidance on setting up and using the new Clickhouse storage driver.
-
Chores
- Modified GitHub Actions workflows to enhance CI/CD processes, including adjustments in the triggering conditions for better automation.
[!WARNING]
Review failed
The pull request is closed.
Walkthrough
The update introduces a Clickhouse storage driver for Go applications using the clickhouse-go
library, adding functionalities for data management, connection handling, and configuration. It integrates with the Fiber framework, offering methods for setting, retrieving, deleting, and resetting data in the ClickHouse database. Additionally, workflows for testing, benchmarking, and release management via GitHub Actions have been established, ensuring robust and maintainable integration.
Changes
File(s) | Change Summary |
---|---|
clickhouse/README.md |
Added documentation for ClickHouse storage driver setup and usage. |
clickhouse/clickhouse.go |
Introduced clickhouse package with Storage struct and methods for data operations. |
clickhouse/clickhouse_test.go |
Added test and benchmark functions for ClickHouse storage operations. |
clickhouse/config.go |
Implemented configuration setup for ClickHouse connections. |
.github/workflows/test-clickhouse.yml |
Created GitHub Actions workflow for testing ClickHouse. |
.github/workflows/test-cloudflarekv.yml |
Updated workflow to trigger on specific paths for Cloudflare KV project. |
.github/workflows/benchmark.yml |
Added workflow step to start ClickHouse server for benchmarks. |
.github/dependabot.yml |
Added dependency update configuration for ClickHouse package ecosystem. |
.github/release-drafter-clickhouse.yml , .github/workflows/release-drafter-clickhouse.yml |
Configured release drafter for ClickHouse changes. |
Sequence Diagram(s)
sequenceDiagram
participant App
participant ClickhouseDriver
participant ClickhouseDB
App->>ClickhouseDriver: New(config)
ClickhouseDriver-->>ClickhouseDB: Connect with config
ClickhouseDB-->>ClickhouseDriver: Connection Established
App->>ClickhouseDriver: Set(key, value, expiration)
ClickhouseDriver->>ClickhouseDB: Insert data
ClickhouseDB-->>ClickhouseDriver: Data Inserted
App->>ClickhouseDriver: Get(key)
ClickhouseDriver->>ClickhouseDB: Query data
ClickhouseDB-->>ClickhouseDriver: Return data
App->>ClickhouseDriver: Delete(key)
ClickhouseDriver->>ClickhouseDB: Delete data
ClickhouseDB-->>ClickhouseDriver: Data Deleted
App->>ClickhouseDriver: Reset()
ClickhouseDriver->>ClickhouseDB: Reset table
ClickhouseDB-->>ClickhouseDriver: Table Reset
App->>ClickhouseDriver: Close()
ClickhouseDriver->>ClickhouseDB: Close connection
ClickhouseDB-->>ClickhouseDriver: Connection Closed
Assessment against linked issues
Objective | Addressed | Explanation |
---|---|---|
Implement ClickHouse storage driver with control over the table engine (#1204) | ✅ | |
Provide methods for setting, getting, deleting, and resetting data in ClickHouse (#1204) | ✅ |
Poem
In code, we find the magic hue, ClickHouse binds, our data new, Set and get, delete with grace, A storage treat in this vast space. 🐇📦✨
[!TIP]
AI model upgrade
gpt-4o
model for reviews and chat is now liveOpenAI claims that this model is better at understanding and generating code than the previous models. Please join our Discord Community to provide any feedback or to report any issues.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>.
-
Generate unit testing code for this file.
-
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitai
in a new review comment at the desired location with your query. Examples:-
@coderabbitai generate unit testing code for this file.
-
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitai
in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai generate interesting stats about this repository and render them as a table.
-
@coderabbitai show all the console.log statements in this repository.
-
@coderabbitai read src/utils.ts and generate unit testing code.
-
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
-
@coderabbitai help me debug CodeRabbit configuration file.
-
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
-
@coderabbitai pause
to pause the reviews on a PR. -
@coderabbitai resume
to resume the paused reviews. -
@coderabbitai review
to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full review
to do a full review from scratch and review all the files again. -
@coderabbitai summary
to regenerate the summary of the PR. -
@coderabbitai resolve
resolve all the CodeRabbit review comments. -
@coderabbitai configuration
to show the current CodeRabbit configuration for the repository. -
@coderabbitai help
to get help.
Additionally, you can add @coderabbitai ignore
anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml
)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yaml
file to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Taking a look at the failing checks already
@luk3skyw4lker The go.mod files are still broken. You edited the root one
@gaby fixed it, sorry to take so long!
@luk3skyw4lker The benchmark yml has to be updated to run clickhouse
@gaby I added the clickhouse startup command, should be ok right now
@gaby the latest commit should fix the error in the benchmark, I changed the clickhouse port to 9001
@gaby the latest commit should fix the error in the benchmark, I changed the clickhouse port to 9001
Few comments, benchmarks are working now 💪
I'm almost done with all the comments, probably will send some code by end of the week. Sorry to not do it sooner!
@luk3skyw4lker Thanks!
@luk3skyw4lker thanks, just ping us when you are done
@gaby @ReneWerner87 it's all done, compression is added. Sorry to take so long, I was trying to find a way to support all compression codecs but didn't manage to, so I went through with gaby's solution of adding just ZSTD(1) compression to all columns
Will check it tomorrow
@luk3skyw4lker Overall looks good, just two comments
@gaby I'll fix them tomorrow morning, thanks!
@gaby I'll fix them tomorrow morning, thanks!
Sounds good 💪
@ReneWerner87 @gaby I think it's all done!
@luk3skyw4lker Run go mod tidy
inside clickhouse folder. Will review after work
@gaby done!
@luk3skyw4lker There's a issue somewhere in the implementation. The tests fail/pass based on timing
@luk3skyw4lker I think callig driver.Context is sharing context between tests. I've seen this happen with Prometheus too.
@gaby yeah, I'll have to check this later, tried some stuff but it didn't solve the issue, I'll try it tomorrow morning when I have the time
It doesn't seems like the sharing context it's the issue tho, I removed all driver.Context calls and tested it with creating a context.Background() for each separately call and the same error was raised, I'm gonna keep checking it out while I have the time
Alright, found out what was going on, even when the expiration value was equal the zero value of the time.Time struct, the IsZero function was returning false, so I changed the comparision and everything works out now. Committing the solution right this instant
@gaby I addressed your changes and fixed the issues the driver was having, could you check again please?