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

Improve library "ergonomics" #6

Closed
3 tasks done
mareek opened this issue Jun 23, 2023 · 2 comments
Closed
3 tasks done

Improve library "ergonomics" #6

mareek opened this issue Jun 23, 2023 · 2 comments
Assignees

Comments

@mareek
Copy link
Owner

mareek commented Jun 23, 2023

Following the discussion in #5 , I will limit the public surface of the API and add more comments for developers that want to dig further than the few methods in the Uuid static class.

  • make all generators internal as they are not meant to be used directly (or maybe just their constructors ?)
  • remove non used generators (V3 and V6)
  • add some comments in UuidV8SqlServerGenerator to explain the reasons of this implementation (see UUIDs are not sorted properly in a MSSQL DB at scale #2)
@mareek mareek self-assigned this Jun 23, 2023
@QianMoXi
Copy link

QianMoXi commented Dec 8, 2023

I noticed that the new method of the UuidTimestampGeneratorBase class has been changed to internal in version 3.0.0-beta, can it be modified back to public?

Because I support Sql Server and My SQL in the same app, and I injected the UuidTimestampGeneratorBase class into DI to generate IDs for different rules.

@mareek
Copy link
Owner Author

mareek commented Dec 20, 2023

The reason that I'm making the generator classes internal is to prevent some misuse I've seen in some code base. These classes were not intended to be used outside of the library; it was a sloppy move from my part not to make them internal from the start.

For your use case, I recommend writing some code like this and using IUuidGenerator in the places where you used UuidTimestampGeneratorBase

using UUIDNext;
public interface IUuidGenerator 
{ 
    Guid NewUuid(); 
}

public class SqlServerUuidGenerator : IUuidGenerator 
{ 
    public Guid NewUuid() => Uuid.NewDatabaseFriendly(Database.SqlServer); 
}

public class MySqlUuidGenerator : IUuidGenerator 
{ 
    public Guid NewUuid() => Uuid.NewDatabaseFriendly(Database.Other); 
}

You can also still use UUIDNext V2.0.2, there are no significant change in the UUID generation.

P.S. Sorry for the delay in answering your comment

@mareek mareek closed this as completed in 7292787 Dec 20, 2023
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

No branches or pull requests

2 participants