-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
lua: timestamp in millis #14522
lua: timestamp in millis #14522
Conversation
Hi @mindyor, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
Thanks, @mindyor! Lua API looks good. Could you fix CI? |
@mindyor, do you want me to help you to finish this PR? :). |
@mindyor when you have time, please have a look at https://github.com/envoyproxy/envoy/compare/main...dio:lua-timestamp-millis-updated?expand=1. I added two commits (one of them is to "rebase" it with the current main branch "main", the second one is to make it compiles). I think we need to add tests for running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests when calling registerGlobal
(most likely you need to add it in test/extensions/filters/common/lua/lua_test.cc
).
tls_slot_->runOnAllThreads([global](OptRef<LuaThreadLocal> tls) { | ||
uint64_t ThreadLocalState::registerGlobal(const std::string& global, | ||
const InitializerList& initializers) { | ||
tls_slot_->runOnAllThreads([global, &initializers](OptRef<LuaThreadLocal> tls) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my bad, seems like we need to copy the initializers
vector.
tls_slot_->runOnAllThreads([global, initializers](OptRef<LuaThreadLocal> tls) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Changed.
@@ -22,7 +22,7 @@ void Coroutine::start(int function_ref, int num_args, const std::function<void() | |||
|
|||
state_ = State::Yielded; | |||
lua_rawgeti(coroutine_state_.get(), LUA_REGISTRYINDEX, function_ref); | |||
ASSERT(lua_isfunction(coroutine_state_.get(), -1)); | |||
ASSERT(lua_isfunction(coroutine_state_.get(), -1) == 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you comment why this needs to be exactly 1? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm it may not be. Taking this out
This |
/retest |
Retrying Azure Pipelines: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. A request to expand the docs a bit more. Thanks!
timestamp = handle:timestamp(format) | ||
|
||
High resolution timestamp function. *format* is an optional string parameter to indicate the format of the timestamp. | ||
*milliseconds_since_epoch* and *nanoseconds_since_epoch* are supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to document the exported enums here?
@@ -33,6 +33,7 @@ Minor Behavior Changes | |||
instead of `//source/common/chromium_url`. The new path canonicalizer is enabled by default. To | |||
revert to the legacy path canonicalizer, enable the runtime flag | |||
`envoy.reloadable_features.remove_forked_chromium_url`. | |||
* lua: added function `timestamp` to provide high resolution timestamps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you expand this, so we are aware of the enums.
64cf446
to
127c801
Compare
127c801
to
df5e616
Compare
Signed-off-by: mindyor <[email protected]>
Signed-off-by: mindyor <[email protected]>
df5e616
to
8ba3f45
Compare
Looks like you need to merge main. Quite a few conflicts |
Signed-off-by: mindyor <[email protected]>
Signed-off-by: mindyor <[email protected]>
Signed-off-by: mindyor <[email protected]>
Signed-off-by: mindyor <[email protected]>
Signed-off-by: mindyor <[email protected]>
Signed-off-by: mindyor <[email protected]>
Signed-off-by: mindyor <[email protected]>
Signed-off-by: mindyor <[email protected]>
Signed-off-by: mindyor <[email protected]>
…y lua int limits. update documentation Signed-off-by: mindyor <[email protected]>
8ba3f45
to
488bcb7
Compare
Signed-off-by: mindyor <[email protected]>
Signed-off-by: mindyor <[email protected]>
Signed-off-by: mindyor <[email protected]>
/retest |
Retrying Azure Pipelines: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @mindyor! Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Commit Message: add Lua function to get timestamp in milliseconds and nanoseconds
Additional Description: Description: adds Lua function to get timestamp in higher resolution. Resolutions are: milliseconds since epoch. Resolution defaults to milliseconds since epoch.
Risk Level: low
Testing: added unit tests for default case, resolution levels, and invalid input
Docs Changes: added documentation for function in
lua_filter.rst
Release Notes: added release note in
version_history.rst
Platform Specific Features: n/a
[Optional Runtime guard:]
[Optional Fixes #Issue] #10282
[Optional Deprecated:]
((an update of #10329))