Skip to content

Add support for repetition and ISO 8601 for reminders - #974

Merged
halspang merged 1 commit into
dapr:masterfrom
yash-nisar:iso_8601_intervals
Jan 27, 2023
Merged

halspang merged 1 commit into
dapr:masterfrom
yash-nisar:iso_8601_intervals

Conversation

@yash-nisar

Copy link
Copy Markdown
Contributor

Closes #702

Signed-off-by: Yash Nisar yashnisar@microsoft.com

Description

Add support for reptition and ISO 8601 for reminders

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #702

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • [] Extended the documentation

@yash-nisar
yash-nisar requested review from a team as code owners October 24, 2022 15:36
@codecov

codecov Bot commented Oct 24, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #974 (c8fd5a9) into master (1605ecd) will decrease coverage by 0.01%.
The diff coverage is 53.60%.

@@            Coverage Diff             @@
##           master     #974      +/-   ##
==========================================
- Coverage   70.17%   70.16%   -0.01%     
==========================================
  Files         160      160              
  Lines        5284     5377      +93     
  Branches      567      583      +16     
==========================================
+ Hits         3708     3773      +65     
- Misses       1442     1464      +22     
- Partials      134      140       +6     
Flag Coverage Δ
net6 70.09% <53.60%> (+0.01%) ⬆️
net7 70.09% <53.60%> (+0.01%) ⬆️
netcoreapp3.1 70.13% <53.60%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/Dapr.Actors/Resources/SR.Designer.cs 34.04% <0.00%> (-0.75%) ⬇️
src/Dapr.Actors/Runtime/Actor.cs 60.58% <0.00%> (-12.23%) ⬇️
src/Dapr.Actors/Runtime/ActorReminder.cs 43.20% <43.33%> (+23.60%) ⬆️
src/Dapr.Actors/Runtime/ConverterUtils.cs 92.98% <87.87%> (-7.02%) ⬇️
src/Dapr.Actors/Runtime/ActorReminderOptions.cs 100.00% <100.00%> (ø)
...rc/Dapr.Actors/Runtime/DefaultActorTimerManager.cs 30.76% <100.00%> (+18.76%) ⬆️
src/Dapr.Actors/Runtime/ReminderInfo.cs 97.67% <100.00%> (+0.23%) ⬆️
src/Dapr.Client/DaprClientGrpc.cs 87.27% <0.00%> (-0.14%) ⬇️
src/Dapr.Actors/Runtime/ActorReminderToken.cs 64.70% <0.00%> (+11.76%) ⬆️
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@yash-nisar yash-nisar changed the title Add support for reptition and ISO 8601 for reminders Add support for repetition and ISO 8601 for reminders Oct 24, 2022

@halspang halspang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change that I'd also feel better about if we had e2e tests. When we change how a data type like this goes to the runtime, it's always good to validate that the runtime does in fact understand it.

Comment thread examples/Actor/DemoActor/DemoActor.cs Outdated
Comment thread src/Dapr.Actors/Runtime/ActorReminder.cs Outdated
Comment thread src/Dapr.Actors/Runtime/ActorReminder.cs Outdated
Comment thread src/Dapr.Actors/Runtime/ConverterUtils.cs Outdated
Comment thread src/Dapr.Actors/Runtime/ConverterUtils.cs Outdated
Comment thread src/Dapr.Actors/Runtime/ReminderInfo.cs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because IDaprInteractors was not accessible.

Error: Dapr.Actors.Runtime.DefaultActorTimerManagerTests.RegisterReminderAsync_WithRepetition_CallsInteractor_WithCorrectData: Castle.DynamicProxy.Generators.GeneratorException : Can not create proxy for type Dapr.Actors.IDaprInteractor because it is not accessible. Make it public, or internal and mark your assembly with [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] attribute, because assembly Dapr.Actors is strong-named.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you did this for the test. I'd argue that you should just make a small implementation of the interface instead of changing this property.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts? I'm still not convinced we need this and I don't want to change the visibility like this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only other option is to make the visibility of the interactor public which will cause a domino effect will lead to inconsistent accessibility issue. The param ActorMessageSerializersManager will also have to be public, etc and the chain would continue. Do you know if there is a better way to mock the interactor ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, implement it :) You're only doing one method so just create a stub implementation that does what your mock does.

Comment thread test/Dapr.Actors.Test/DaprFormatTimeSpanTests.cs Outdated
@yash-nisar
yash-nisar force-pushed the iso_8601_intervals branch 2 times, most recently from d51cdd2 to 9d04f3e Compare January 20, 2023 03:28
@yash-nisar

Copy link
Copy Markdown
Contributor Author

The IT test failure is unrelated to my change.

@yash-nisar
yash-nisar requested a review from halspang January 20, 2023 03:38
Comment thread src/Dapr.Actors/Runtime/Actor.cs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you got this from above, but is -1 even a valid period? I think an empty period is actually correct and -1 may be invalid.

https://docs.dapr.io/reference/api/actors_api/#create-actor-reminder

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw that we're accepting values > 0 for repetitions. So, getting rid of that statement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement feels odd to me. -1 is a special case I'm guessing? Would we be calling it with that at any time instead of just not setting it? Couldn't we just say anything <0 is a valid way to say infinite repetitions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception should include the value range since we know it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be optional, yeah? int?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you did this for the test. I'd argue that you should just make a small implementation of the interface instead of changing this property.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Missing a space.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code probably uses System.Text.Json instead of Newtonsoft, you should as well to ensure we don't have any weird serializer issues.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 42 to 43

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Period and due time are booleans?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data.TryGetValue() returns a boolean stating whether the property exists in the json object or not. But I have changed it anyway.

@yash-nisar
yash-nisar force-pushed the iso_8601_intervals branch 2 times, most recently from 267400b to 2eb3bcc Compare January 25, 2023 22:46
@yash-nisar

Copy link
Copy Markdown
Contributor Author

Test failure is unrelated to my change.

Comment on lines 148 to 200

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (repetitions != null && repetitions <= 0) {
...
}

Feels like we need that ^.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 176 to 224

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment should include optional like Ttl above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts? I'm still not convinced we need this and I don't want to change the visibility like this.

Comment thread src/Dapr.Actors/Runtime/ReminderInfo.cs Outdated
Comment on lines 45 to 47

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should've asked this earlier, but how do ttl and repetitions interact? Is it OK to have both?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very good catch, on reading the docs, I found that it is OK to have both. Adding a method overload.

Comment thread src/Dapr.Actors/Runtime/ReminderInfo.cs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this not be default valued? I know we can set it as null but we are forcing the set.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@halspang halspang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main thing is to switch around some stuff in the tests.

Comment on lines 24 to 27

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this shouldn't be here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is for testing, it should be in the testing project otherwise this is included in all projects that use the dapr libraries.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 29 to 32

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this was also for the test, I think we should remove it. I'd prefer that interface exist in the test project instead of being included in the main library.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 27 to 28

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's here where I was saying a simple impl of the interface would mean we don't need to use a mock at all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the TTL test, we should check that things don't change after we expect the reminder to be gone.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Yash Nisar <yashnisar@microsoft.com>
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.

Add support for ISO 8601 intervals

2 participants