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

Replaced erlang:now with erlang:timestamp #87

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Replaced erlang:now with erlang:timestamp #87

wants to merge 3 commits into from

Conversation

TBK145
Copy link

@TBK145 TBK145 commented Oct 1, 2015

Replaced erlang:now with erlang:timestamp as erlang:now is deprecated in Erlang 18.

@TBK145
Copy link
Author

TBK145 commented Oct 1, 2015

Here is the issue I created about it: #86.

@nickelization
Copy link
Contributor

Hi Thijs, thanks for the contribution! However, we currently need to maintain backwards compatibility with Erlang R16, which does not have the erlang:timestamp function. Once we're at a point where we can drop support for previous Erlang versions, then we may be ready to migrate to erlang:timestamp, but for the time being I think we will unfortunately need to stick with erlang:now.

@nickelization
Copy link
Contributor

I'm also concerned about potential race conditions that might occur, since unlike erlang:now, erlang:timestamp does not guarantee that consecutive calls on the same node return monotonically increasing values. I'm not sure if this would actually be an issue, but I'd need to look over the code some more and experiment....

@nickelization
Copy link
Contributor

On the other hand, if your issue is just that warnings_as_errors is enabled and you can't get riak_ensemble to compile under R18, I would be happy to consider a pull request that adds the nowarn_deprecated_function compile flag :)

@cmeiklejohn
Copy link
Contributor

The recommended approach here is to use time_compat to ensure that you have backwards compatibility. We just addressed this in Lasp, our support libraries, and our fork of Helium's Plumtree.

@cmeiklejohn
Copy link
Contributor

👎 to the approach that adds the nowarn_deprecated_function flag.

@TBK145
Copy link
Author

TBK145 commented Oct 6, 2015

So I guess both these occurrences can be replaced by erlang:unique_integer() using the time_compat library?

@nickelization
Copy link
Contributor

@cmeiklejohn Thanks for the info on time_compat, I didn't know about that module/approach (though I guess I should've figured someone had written something like that). Anyway, I agree, that would definitely be nicer than resorting to nowarn_deprecated_function.

@cmeiklejohn
Copy link
Contributor

We've put it in a standalone library so we can include it in the Lasp libraries, given you run into problems if you just copy time_compat in if two (or more) packages both include it.

https://github.com/lasp-lang/time_compat

@jadeallenx
Copy link
Contributor

Thanks @cmeiklejohn! Sometimes Erlang's flat module namespace can be a real PITA.

@jadeallenx jadeallenx closed this Oct 6, 2015
@jadeallenx jadeallenx reopened this Oct 6, 2015
@jadeallenx
Copy link
Contributor

Sorry hit the wrong button 😝

@TBK145
Copy link
Author

TBK145 commented Oct 7, 2015

This time I used the time_compat library, which also removed the use of timestamp/1 in synctree_leveldb.erl. Just like in riak_core I used time_compat:timestamp/0 once, because the original format was a timestamp as well. Let me know if this should be changed.

yurrriq added a commit to yurrriq/riak_ensemble that referenced this pull request Apr 5, 2016
chrisbailey4 pushed a commit to Invotas/riak_ensemble that referenced this pull request Jul 22, 2016
chrisbailey4 pushed a commit to Invotas/riak_ensemble that referenced this pull request Jul 22, 2016
@mdaiter
Copy link

mdaiter commented Jan 31, 2017

Bump.

I'd also recommend os:timestamp(), as it's backwards compatible on Erlang R16

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.

5 participants