Skip to content

feat: add ksuid algorithm on request-id plugin#12573

Merged
Baoyuantop merged 3 commits into
apache:masterfrom
laz-xyr:feat-ksuid
Sep 5, 2025
Merged

feat: add ksuid algorithm on request-id plugin#12573
Baoyuantop merged 3 commits into
apache:masterfrom
laz-xyr:feat-ksuid

Conversation

@laz-xyr

@laz-xyr laz-xyr commented Sep 1, 2025

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:

Feat # #12559
This pr introduces the ksuid algorithm for request-id which generates a sequential ID always 27 characters encoded in alphanumeric base62 that will lexicographically sort by timestamp. retain their time-ordered property through a string and it enough 128-bit of randomness to provide strong protection against collisions (duplicates),more than uuid
e.g.

ksuid:325ghCANEKjw6Jsfejg5p6QrLYB
REPRESENTATION:

    String: 325ghCANEKjw6Jsfejg5p6QrLYB
    Raw: 15430DBBD7F68AD7CA0AE277772AB36DDB1A3C13

COMPONENTS:

    Time: 2025-09-01 16:39:23 +0800 CST
    Timestamp: 356715963
    Payload: D7F68AD7CA0AE277772AB36DDB1A3C13

Checklist

  • [√] I have explained the need for this PR and the problem it solves
  • [√] I have explained the changes or the new features added to this PR
  • [√ ] I have added tests corresponding to this change
  • [√ ] I have updated the documentation to reflect this change
  • [√ ] I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Sep 1, 2025
@moonming
moonming requested a review from Copilot September 2, 2025 01:31

Copilot AI left a comment

Copy link
Copy Markdown

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 the ksuid algorithm as a new option for the request-id plugin, enabling generation of 27-character sequential IDs that are lexicographically sortable by timestamp with strong collision protection.

  • Introduces ksuid as a new algorithm option alongside existing uuid, nanoid, and range_id algorithms
  • Adds comprehensive test coverage for the new ksuid functionality including validation of ID format and uniqueness
  • Updates documentation in both English and Chinese to describe the new ksuid algorithm and provide usage examples

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
apisix/plugins/request-id.lua Adds ksuid algorithm support and dependency import
apisix-master-0.rockspec Adds lua-resty-ksuid dependency
t/plugin/request-id3.t New test file for ksuid algorithm validation
docs/en/latest/plugins/request-id.md English documentation updates for ksuid algorithm
docs/zh/latest/plugins/request-id.md Chinese documentation updates for ksuid algorithm

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

Comment thread docs/en/latest/plugins/request-id.md Outdated
Comment thread docs/en/latest/plugins/request-id.md Outdated
Comment thread docs/en/latest/plugins/request-id.md Outdated
Comment thread t/plugin/request-id3.t Outdated
ngx.say(id)
return
end

Copilot AI Sep 2, 2025

Copy link

Choose a reason for hiding this comment

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

Remove trailing whitespace on this line to maintain code cleanliness.

Suggested change

Copilot uses AI. Check for mistakes.
Comment thread apisix/plugins/request-id.lua Outdated
Comment thread docs/zh/latest/plugins/request-id.md Outdated
@laz-xyr

laz-xyr commented Sep 2, 2025

Copy link
Copy Markdown
Contributor Author

code and translation has been adjusted

@Baoyuantop Baoyuantop moved this to 👀 In review in ⚡️ Apache APISIX Roadmap Sep 2, 2025
@Baoyuantop Baoyuantop linked an issue Sep 2, 2025 that may be closed by this pull request
@laz-xyr

laz-xyr commented Sep 2, 2025

Copy link
Copy Markdown
Contributor Author

I correct code style issues on ci , need you review and approval again @Baoyuantop

@Baoyuantop
Baoyuantop self-requested a review September 3, 2025 08:50
@Baoyuantop
Baoyuantop merged commit 18884bc into apache:master Sep 5, 2025
32 of 34 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in ⚡️ Apache APISIX Roadmap Sep 5, 2025
jizhuozhi pushed a commit to jizhuozhi/apisix that referenced this pull request Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

feat: ksuid implementation on request-id plugin

5 participants