Skip to content
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

Add Cloudflare KV Storage #1298

Merged
merged 70 commits into from
Apr 16, 2024
Merged

Add Cloudflare KV Storage #1298

merged 70 commits into from
Apr 16, 2024

Conversation

Geun-Oh
Copy link
Contributor

@Geun-Oh Geun-Oh commented Mar 21, 2024

Hello guys. This PR is for the new Storage implementation of Cloudflare KV.

Thanks for the reviews.

Summary by CodeRabbit

  • New Features
    • Introduced a CloudflareKV storage driver for Go applications, enabling key-value storage operations.
    • Added test functions for setting, getting, deleting, resetting, and closing operations on Cloudflare KV storage.
  • Chores
    • Set up GitHub Actions workflow for release drafting specifically for changes in the cloudflarekv/ directory.
  • Documentation
    • Updated README.md with instructions, examples, and configuration details for using the CloudflareKV storage driver in Go applications.
    • Added a configuration struct and helper function details in config.go for Cloudflare storage settings.

@Geun-Oh Geun-Oh requested a review from a team as a code owner March 21, 2024 17:30
@Geun-Oh Geun-Oh requested review from gaby, sixcolors, ReneWerner87 and efectn and removed request for a team March 21, 2024 17:30
Copy link
Contributor

coderabbitai bot commented Mar 21, 2024

Walkthrough

The recent project updates focus on expanding the testing capabilities for Cloudflare KV storage. Test functions now cover essential operations like setting, getting, deleting, resetting, and closing. Moreover, benchmark tests have been integrated to gauge performance metrics effectively.

Changes

File Path Change Summary
.../cloudflarekv_test.go Introduces tests for set, get, delete, reset, close operations; adds benchmark tests.

Poem

🐇🌟
Amid the code's intricate sprawl,
Tests dance, answering the call.
Set, get, delete, all align,
Benchmarks clock the time's design.
Data fields in patterns twine,
A rabbit's touch, code's lifeline. 🌿🚀


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?

Share
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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6fa3ab0 and c424c66.
Files ignored due to path filters (2)
  • kv/go.mod is excluded by: !**/*.mod
  • kv/go.sum is excluded by: !**/*.sum
Files selected for processing (8)
  • .github/dependabot.yml (1 hunks)
  • .github/release-drafter-kv.yml (1 hunks)
  • .github/workflows/release-drafter-kv.yml (1 hunks)
  • .github/workflows/test-kv.yml (1 hunks)
  • kv/README.md (1 hunks)
  • kv/config.go (1 hunks)
  • kv/kv.go (1 hunks)
  • kv/kv_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • .github/release-drafter-kv.yml
Additional comments: 6
.github/workflows/release-drafter-kv.yml (1)
  • 1-19: The workflow configuration for the Release Drafter KV looks correct and well-structured. It's specifically tailored to handle changes in the kv/ directory, which aligns with the PR's objectives. Ensure that the release-drafter-kv.yml configuration file exists and is correctly set up to match this workflow's expectations.
.github/workflows/test-kv.yml (1)
  • 1-29: The automated testing workflow for the KV storage feature is well-defined, covering the latest three Go versions. This ensures compatibility and reliability across different environments. It's a good practice to keep the Go versions updated to the latest stable releases to catch any potential issues early.
kv/config.go (1)
  • 3-52: The Config struct and the default configuration for the Cloudflare KV storage are well-defined, covering essential parameters like authentication details and namespace identifiers. The helper function configDefault ensures that default values are used when no custom configuration is provided. Consider documenting the behavior of the Reset flag more clearly, explaining its impact on existing data.
kv/README.md (2)
  • 6-6: The use of badges in the README provides quick insights into the project's status. However, ensure that the links for the badges are correctly set up and pointing to the relevant workflows and metrics for the KV storage feature.
  • 12-12: The description of the KV storage driver as "a kv storage driver" might be improved for clarity. Consider specifying that it's a "Cloudflare KV storage driver for Go applications" to provide immediate context to the reader.
.github/dependabot.yml (1)
  • 59-64: The addition of a Dependabot configuration for the gomod package ecosystem in the /kv/ directory is a proactive step towards maintaining up-to-date dependencies. Setting the update interval to weekly strikes a good balance between staying current and minimizing disruption. Ensure that the /kv/ directory contains Go module files (go.mod) for Dependabot to operate correctly.

kv/kv_test.go Outdated Show resolved Hide resolved
kv/kv.go Outdated Show resolved Hide resolved
kv/kv.go Outdated Show resolved Hide resolved
.github/dependabot.yml Outdated Show resolved Hide resolved
kv/kv_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c424c66 and 85133f6.
Files ignored due to path filters (2)
  • cloudflarekv/go.mod is excluded by: !**/*.mod
  • cloudflarekv/go.sum is excluded by: !**/*.sum
Files selected for processing (8)
  • .github/dependabot.yml (1 hunks)
  • .github/release-drafter-cloudflarekv.yml (1 hunks)
  • .github/workflows/release-drafter-cloudflarekv.yml (1 hunks)
  • .github/workflows/test-cloudflarekv.yml (1 hunks)
  • cloudflarekv/README.md (1 hunks)
  • cloudflarekv/cloudflarekv.go (1 hunks)
  • cloudflarekv/cloudflarekv_test.go (1 hunks)
  • cloudflarekv/config.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • .github/release-drafter-cloudflarekv.yml
Files skipped from review as they are similar to previous changes (1)
  • .github/dependabot.yml
Additional comments: 2
.github/workflows/test-cloudflarekv.yml (1)
  • 1-29: This workflow configuration for testing Cloudflare KV is well-structured and follows best practices, including testing across multiple Go versions. Good job!
cloudflarekv/cloudflarekv_test.go (1)
  • 16-17: Consider handling the .env file loading failure more gracefully. Instead of immediately terminating the test execution with log.Fatal, you could skip the tests that require environment variables with t.Skip("Environment variables not set. Skipping tests."). This approach allows other tests to run even if the .env file is missing or environment variables are not set.

.github/workflows/release-drafter-cloudflarekv.yml Outdated Show resolved Hide resolved
cloudflarekv/config.go Outdated Show resolved Hide resolved
cloudflarekv/cloudflarekv.go Outdated Show resolved Hide resolved
cloudflarekv/README.md Outdated Show resolved Hide resolved
Geun-Oh and others added 2 commits March 22, 2024 02:53
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
cloudflarekv/README.md Outdated Show resolved Hide resolved
cloudflarekv/README.md Outdated Show resolved Hide resolved
@ReneWerner87
Copy link
Member

@Geun-Oh this is enough
1ae7fa0

the permission info is already on the script

@Geun-Oh
Copy link
Contributor Author

Geun-Oh commented Apr 9, 2024

@Geun-Oh this is enough 1ae7fa0

the permission info is already on the script

Thanks for your help

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

.github/scripts/initialize-wrangler.sh Show resolved Hide resolved
@ReneWerner87
Copy link
Member

@gaby @efectn can you check again

.github/dependabot.yml Outdated Show resolved Hide resolved
.github/workflows/test-cloudflarekv.yml Outdated Show resolved Hide resolved
cloudflarekv/cloudflarekv_test.go Outdated Show resolved Hide resolved
@Geun-Oh
Copy link
Contributor Author

Geun-Oh commented Apr 11, 2024

@gaby Thanks for your reviews. I checked and made tests with local initialization of storages.

@Geun-Oh
Copy link
Contributor Author

Geun-Oh commented Apr 12, 2024

I've got an issue with dev cloudflare worker server...it returns success often with GET http call because of caching. So testing fails sometimes. I'll fix it and call you guys :)

It might occur because of The get() method may return stale values. If a given key has recently been read in a given location, changes to the key made in other locations may take up to 60 seconds to display. from docs.

If anyone has an idea with it. Please let me know!

@Geun-Oh
Copy link
Contributor Author

Geun-Oh commented Apr 12, 2024

I made test clear. GET works well.

@Geun-Oh
Copy link
Contributor Author

Geun-Oh commented Apr 16, 2024

Hello. If there's anything else I need to proceed with, please let me know.

@gaby
Copy link
Member

gaby commented Apr 16, 2024

Ping @gofiber/maintainers

@ReneWerner87 ReneWerner87 merged commit 79b8fb1 into gofiber:main Apr 16, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants