Skip to content

v8.3.0

Choose a tag to compare

@Tynab Tynab released this 19 May 17:35
· 88 commits to main since this release
95a8dbb

YANLib 8.3.0 - Snowflake ID Implementation & Customizable Distributed Identifiers

Distributed ID Generation

  • Snowflake Algorithm Integration

    • Added robust implementation of the Snowflake ID algorithm for distributed systems
    • Implemented 64-bit unique ID generation with timestamp, worker ID, datacenter ID, and sequence components
    • Full support for time-ordered, sortable identifiers with millisecond precision
    • Thread-safe implementation for concurrent ID generation in multi-threaded environments
  • Predefined Bit Allocation Strategies

    • Added BitAllocationStrategy enum for simplified bit allocation configuration

    • Included four predefined strategies optimized for different use cases:

      • Default (5-5-13): Balanced approach for most applications
      • MoreDistributed (10-10-3): Optimized for systems with many workers and datacenters
      • HighVolume (2-2-19): Optimized for generating many IDs per millisecond on few nodes
      • Balanced (8-8-7): Middle ground between distribution and sequence capacity
    • Simplified constructor overloads for intuitive API usage

    • Automatic validation of worker and datacenter IDs based on selected strategy

  • Customizable Bit Allocation

    • Added support for customizing bit allocation between worker ID, datacenter ID, and sequence components
    • Flexible configuration to optimize for different distributed system requirements
    • Automatic validation to ensure the total bit allocation remains within the 64-bit constraint
    • Runtime calculation of maximum values based on configured bit allocations
  • String Representation Support

    • Added base-26 alphabetic (A-Z) string representation for more compact IDs
    • Implemented base-36 alphanumeric (0-9, A-Z) encoding for maximum compactness
    • Bidirectional conversion between numeric IDs and string representations
    • Support for custom epoch timestamps for application-specific time ranges

Performance

  • Optimized bit manipulation operations for efficient ID composition
  • High-throughput ID generation with minimal overhead
  • Efficient string conversion algorithms for alphabetic and alphanumeric formats
  • Thread synchronization with minimal contention for concurrent scenarios
  • Automatic sequence handling with configurable capacity per millisecond

Improvements

  • Component extraction methods to retrieve timestamp, worker ID, and datacenter ID from existing IDs
  • Strategy-aware component extraction for simplified ID parsing
  • Clock drift protection to prevent duplicate IDs when system time moves backwards
  • Comprehensive XML documentation for all Snowflake ID-related methods
  • Configurable worker and datacenter IDs for distributed deployment scenarios
  • Seamless integration with existing YANLib components

See full documentation at: https://github.com/Tynab/YANLib/wiki