8000 Return delta by s0l0ist · Pull Request #3 · s0l0ist/ferroid · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Return delta #3

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

Merged
merged 30 commits into from
May 23, 2025
Merged

Return delta #3

merged 30 commits into from
May 23, 2025

Conversation

s0l0ist
Copy link
Owner
@s0l0ist s0l0ist commented May 18, 2025

Snowflake Generator Improvements

This pull request introduces breaking changes and several enhancements to improve usability, extensibility, and async support.

Breaking Changes

Accurate Pending behavior
IdGenStatus::Pending now includes a yield_for duration in milliseconds, indicating exactly when the next ID can be generated.
Previously, it returned now + 1ms, which was arbitrary and less useful for cooperative scheduling.

New Features

Unified SnowflakeGenerator Trait

  • BasicSnowflakeGenerator now uses Cell<ID> internally, aligning with the Lock* and Atomic* implementations under a single SnowflakeGenerator trait.
  • All generator types now implement this trait without requiring &mut self, simplifying generic code and enabling broader composability.

Public SnowflakeGenerator Trait

  • The SnowflakeGenerator trait is now public, allowing external libraries or applications to implement custom generators that integrate with the rest of the library.

Asynchronous Generator Support

  • Generators can now be used in async contexts using the try_next_id_async future, via the SnowflakeGeneratorAsyncExt trait, available via the async-tokio feature flag.
  • This allows non-blocking ID generation in async runtimes like Tokio.

128-bit Snowflake ID Example

  • A new example SnowflakeLongId demonstrates how to implement a 128-bit Snowflake ID.
  • This serves as a reference for extending the ID width beyond 64 bits for applications that require a larger ID space.

@s0l0ist s0l0ist marked this pull request as ready for review May 23, 2025 20:53
@s0l0ist s0l0ist merged commit df83809 into main May 23, 2025
3 checks passed
@s0l0ist s0l0ist deleted the nangelou-return-delta branch May 23, 2025 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0