From f82fe989d8aa2d7f859005c53168f5d86cb146be Mon Sep 17 00:00:00 2001 From: Guillaume Charbonnier Date: Mon, 19 Feb 2024 19:22:56 +0100 Subject: [PATCH] introduce last_active in SequenceInfo --- nats/js/api.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nats/js/api.py b/nats/js/api.py index 4385bc2c..b3ddd578 100644 --- a/nats/js/api.py +++ b/nats/js/api.py @@ -469,8 +469,18 @@ def as_dict(self) -> Dict[str, object]: class SequenceInfo(Base): consumer_seq: int stream_seq: int - # FIXME: Do not handle dates for now. - # last_active: Optional[datetime] + last_active: Optional[datetime.datetime] = None + + @classmethod + def from_response(cls, resp: Dict[str, Any]): + cls._convert_rfc3339(resp, 'last_active') + return super().from_response(resp) + + def as_dict(self) -> Dict[str, object]: + result = super().as_dict() + if self.last_active is not None: + result['last_active'] = self._to_rfc3339(self.last_active) + return result @dataclass