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

added Uuid v1 with random node support #59

Closed
wants to merge 7 commits into from
Closed

added Uuid v1 with random node support #59

wants to merge 7 commits into from

Conversation

liuchong
Copy link

added Uuid v1 with random node support
TODO: support generate node with a real MAC.

In fact in some situations such as in docker, the MAC is virtual. so I think to use a random node seem to be ok then.

please refer to: https://docs.docker.com/v1.8/articles/networking/

@alexcrichton
Copy link
Contributor

Unfortunately the unsafe code here isn't thread-safe, and it seems like trying to guess the MAC of the machine we're one is somewhat of a lost cause? Perhaps this could take the timestamp and the MAC as inputs to the constructor?

@liuchong
Copy link
Author

The "node" and "clock_seq" as given arguments are already in the fn "get_v1", I changed it's name to "new_v1_of". then added another commit to init the static_node use std::sync::{ONCE_INIT, Once}, is it ok that I've added an "extern crate std"?

@alexcrichton
Copy link
Contributor

Ah sorry, I mean that this should continue to not have a dependency on either std or time. Instead the Uuid::new_v1 could be the only function added here and it could take two arguments, one for the MAC address and one for the timestamp perhaps?

pub fn new_v1(timestamp: u64,
                  clock_seq: Option<&[u8; 2]>,
                  node: &[u8; 6])
                  -> Uuid {...
@liuchong
Copy link
Author

9108a02
Do you mean like this? (also, what do you think of if the clock_seq need to be in the parameters list?)

seems some usless, and it's almost the same as "from_fields".

@alexcrichton
Copy link
Contributor

Yeah I was thinking something like that (although also not having optional parameters which were in turn randomly generated).

I don't think we're really poised to fully provide V1 UUID generation because we don't have a robust method of figuring out what the local MAC address is?

@liuchong
Copy link
Author

liuchong commented May 9, 2016

close for now

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.

None yet

2 participants