Conversation
Motivation: Issue dapr#548 asks for actor TTL support. Actor state TTL is already implemented (SetWithTTL on actor.StateManagerContext, wired through to Dapr's ActorStateOperation.TTLInSeconds), and reminder/timer TTL has existed since 2021. However, actor/mock/mock_server.go — a MockGen generated mock of the interfaces in actor/actor.go — was never regenerated after SetWithTTL was added to StateManagerContext. As a result MockStateManagerContext silently did not implement actor.StateManagerContext, defeating the purpose of the mock for any test that needs to stub the full interface (e.g. to unit test actor code that calls SetWithTTL). No existing code in the repo currently assigns a *MockStateManagerContext to an actor.StateManagerContext-typed variable, so this did not break any existing build or test. The fix only restores the mock's fidelity to its source interface; it does not change any runtime behavior. Approach: - Add the missing SetWithTTL method (and its recorder) to MockStateManagerContext in actor/mock/mock_server.go, matching the exact style of the other generated methods in that file. - Add actor/mock/mock_server_test.go with a compile-time assertion (var _ actor.StateManagerContext = (*MockStateManagerContext)(nil)) so a future interface change that isn't reflected in the mock fails to build instead of failing silently, plus a small gomock-based test exercising the new method. Validation: - go build ./... (passes) - go test ./actor/... (passes, including the new TestMockStateManagerContextSetWithTTL) - gofmt -l on both changed files reports no diffs Fixes dapr#548 Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Author
|
This has been sitting for a bit and is still green and rebased — happy to make any changes if something would help move review along. |
tthophan
approved these changes
Aug 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
Issue #548 asks for actor TTL support. Actor state TTL is already
implemented (SetWithTTL on actor.StateManagerContext, wired through to
Dapr's ActorStateOperation.TTLInSeconds), and reminder/timer TTL has
existed since 2021. However, actor/mock/mock_server.go — a MockGen
generated mock of the interfaces in actor/actor.go — was never
regenerated after SetWithTTL was added to StateManagerContext. As a
result MockStateManagerContext silently did not implement
actor.StateManagerContext, defeating the purpose of the mock for any
test that needs to stub the full interface (e.g. to unit test actor
code that calls SetWithTTL).
No existing code in the repo currently assigns a *MockStateManagerContext
to an actor.StateManagerContext-typed variable, so this did not break
any existing build or test. The fix only restores the mock's fidelity
to its source interface; it does not change any runtime behavior.
Approach:
MockStateManagerContext in actor/mock/mock_server.go, matching the
exact style of the other generated methods in that file.
(var _ actor.StateManagerContext = (*MockStateManagerContext)(nil))
so a future interface change that isn't reflected in the mock fails
to build instead of failing silently, plus a small gomock-based test
exercising the new method.
Validation:
TestMockStateManagerContextSetWithTTL)
Fixes #548
Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com