-
Couldn't load subscription status.
- Fork 4
Open
Labels
part:clientAffects the client codeAffects the client codepart:dispatcherscope:breaking-changeBreaking change, users will need to update their codeBreaking change, users will need to update their codetype:enhancementNew feature or enhancement visitble to usersNew feature or enhancement visitble to users
Description
We could use special values to represent INFINITE and INSTANTANEOUS for the Dispatch.duration field, so the code gets more readable (without the need for comments) and more type-safe.
We could set the type of duration: timedelta | Duration where duration is a enum for example, then we can also use match like this:
match dispatch.duration:
case Duration.INFINITE: ...
case Duration.INSTANTANEOUS: ...
case timedelta(): ... (here we know it is > 0)
case unexpected: assert_never(unexpected)Taking it even a bit further, we could have a PositiveTimedelta object that even guarantee the time is positive.
Originally posted by @llucax in frequenz-floss/frequenz-dispatch-python#54 (comment)
Metadata
Metadata
Assignees
Labels
part:clientAffects the client codeAffects the client codepart:dispatcherscope:breaking-changeBreaking change, users will need to update their codeBreaking change, users will need to update their codetype:enhancementNew feature or enhancement visitble to usersNew feature or enhancement visitble to users