Skip to content

📝 [Proposal]: middleware/requestID -> use faster alternatives #3398

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

Closed
3 tasks done
pjebs opened this issue Apr 9, 2025 · 9 comments
Closed
3 tasks done

📝 [Proposal]: middleware/requestID -> use faster alternatives #3398

pjebs opened this issue Apr 9, 2025 · 9 comments

Comments

@pjebs
Copy link
Contributor

pjebs commented Apr 9, 2025

Feature Proposal Description

Instead of a default generator of uuid, perhaps https://github.com/oklog/ulid which is faster and shorter

Alignment with Express API

N/A

HTTP RFC Standards Compliance

https://github.com/ulid/spec

API Stability

N/A

Feature Examples

Looks like: 01D78XYFJ1PRM1WPBCBT3VHMNV instead of uuid: f81d4fae-7dec-11d0-a765-00a0c91e6bf6

But added advantage of being orderable. UUID's are not orderable.

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have searched for existing issues that describe my proposal before opening this one.
  • I understand that a proposal that does not meet these guidelines may be closed without explanation.
@JIeJaitt
Copy link
Contributor

JIeJaitt commented Apr 9, 2025

In what scenarios does uuid need to be sorted?

@pjebs
Copy link
Contributor Author

pjebs commented Apr 9, 2025

In this scenario (requestId) it probably doesn't matter, unless somehow the request id ends up in a database (maybe some diagnostics service that tracks errors/performance of endpoints).

But if it's in a database, perhaps you don't need to store created_at time field in some scenarios if you were only interested in ordering.

UUID will require a created_at time field. ulid will not (if you aren't interested in exact creation time, but just the ordering)

@JIeJaitt
Copy link
Contributor

JIeJaitt commented Apr 9, 2025

uuid is a library maintained by Google, who pioneered the go language. So I don't see the need to replace the uuid library if it's not a big breakthrough

@JIeJaitt
Copy link
Contributor

JIeJaitt commented Apr 9, 2025

However, perhaps we can customize the use of ulid , as a middleware, through other implementations

@pjebs
Copy link
Contributor Author

pjebs commented Apr 9, 2025

The proposal was just to change the default id generator because it's faster and Fiber is all about speed.

However, perhaps we can customize the use of ulid , as a middleware, through other implementations

The middleware api already allows the user to replace the id generator with whatever they want including ulid.

@JIeJaitt
Copy link
Contributor

JIeJaitt commented Apr 9, 2025

The proposal was just to change the default id generator because it's faster and Fiber is all about speed.

you are right

@gaby
Copy link
Member

gaby commented Apr 9, 2025

@pjebs @JIeJaitt uuid is essential for security libraries, we are not going to swap to a third party just because its faster.

The ulid one doesn't have any releases since 2022

@JIeJaitt
Copy link
Contributor

JIeJaitt commented Apr 9, 2025

it would be better if we made the uuid generation customizable

I would not like to add the other dependency in the fiber core
we should do it like with the json generation
docs.gofiber.io/guide/faster-fiber#custom-json-encoderdecoder

what do you think of this?

@pjebs pjebs closed this as completed Apr 9, 2025
@pjebs
Copy link
Contributor Author

pjebs commented Apr 9, 2025

@JIeJaitt the proposal was just for this middleware. If a user wants to use ulid, they can add the dependency themself.

@pjebs pjebs closed this as not planned Won't fix, can't repro, duplicate, stale Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants