-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Use cached value from sequenceToken
, if possible
#71
Conversation
✅ Build winston-aws-cloudwatch 396 completed (commit c92d0aac43 by @brunogsa) |
I think the reasoning behind this was that you might have several clients pushing to the same log stream. If client A pushes log events, that will update the sequence token for the stream, and client B will need to refresh its token. I suppose the behavior could be optional, but I'm not sure it's a good idea to not refresh the token at all. |
Sorry, I think I wrongly used the term "refreshed" in my PR description above. The token is still being refreshed using the field The cached value is always renewed, as soon as we have a new However, the token doesn't expire. At least not by time. Currently, the code has 2 ways of retrieving a new token: Using method describeLogStreamsIt returns the value Using method putLogEventsIt returns the value ConclusionThe idea behind my PR is calling I have many clients pushing to the same Log Stream and got no problems regarding that. I'm not sure what problems you're foreseeing here. :/ Thanks! |
Thanks for the elaborate documentation! I think I might be misunderstanding my own code. Let me take a look and get back to you. 🙂 |
Okay, so it took me a while to respond. Sorry about that. I think your PR might as well drop the whole However, as I mentioned before, it misses one use case. If you have multiple clients pushing to the same stream, it's going to cause problems: a client that hasn't pushed for a while will keep trying to use its old sequence token, it'll never refresh it, and hence, it'll never be able to push anymore. That was the reasoning behind the whole expiry feature. If you don't pass a In retrospect, perhaps it'd make a lot more sense to conditionally handle rejections from |
Makes sense! Your approach of handling the rejection seems like a good solution to me. Let's tweak the PR later to address it =] |
I've already added it on master, but I still have to actually run it against CloudWatch rather than in tests before I publish a new major version. If you're feeling adventurous, feel free to already install from GitHub though. 😉 |
Cool, thanks! 🙂 Feel free to close this PR if it's no longer necessary. |
Took me a while again, but version 2.0.0 is now out! 🎉 |
Instead of using time to check if
sequenceToken
can be used, I just check if it's cached.If so, I just return it. Otherwise, I fetch it using AWS SDK.
I'm not sure why you were checking the time, since I didn't find anything on AWS SDK docs saying that
sequenceToken
should be refreshed.Let me know if you see any problem in this new piece of code!
Thanks!