def test_from_dict(self): reminder = ActorReminderData.from_dict( 'test_reminder', { 'dueTime': timedelta(seconds=1), 'period': timedelta(seconds=1), 'data': 'cmVtaW5kZXJfc3RhdGU=', }) self.assertEqual('test_reminder', reminder.reminder_name) self.assertEqual(timedelta(seconds=1), reminder.due_time) self.assertEqual(timedelta(seconds=1), reminder.period) self.assertEqual(b'reminder_state', reminder.state)
async def fire_reminder( self, actor_id: ActorId, reminder_name: str, request_body: bytes) -> None: if not self._runtime_ctx.actor_type_info.is_remindable(): raise ValueError( f'{self._runtime_ctx.actor_type_info.type_name} does not implment Remindable.') request_obj = self._message_serializer.deserialize(request_body, object) if isinstance(request_obj, dict): reminder_data = ActorReminderData.from_dict(reminder_name, request_obj) # ignore if request_obj is not dict async def invoke_reminder(actor: Actor) -> Optional[bytes]: reminder = getattr(actor, REMINDER_METHOD_NAME) if reminder is not None: await reminder(reminder_data.reminder_name, reminder_data.state, reminder_data.due_time, reminder_data.period) return None await self._dispatch_internal(actor_id, self._reminder_method_context, invoke_reminder)