Skip to content

Commit 7a49679

Browse files
author
Guillaume Charbonnier
committed
allow opt_start_time usage in StreamSource
Signed-off-by: Guillaume Charbonnier <[email protected]>
1 parent 9f2809d commit 7a49679

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

nats/js/api.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,22 @@ class ExternalStream(Base):
176176
class StreamSource(Base):
177177
name: str
178178
opt_start_seq: Optional[int] = None
179-
# FIXME: Handle time type, omit for now.
180-
# opt_start_time: Optional[str] = None
179+
opt_start_time: Optional[datetime.datetime] = None
181180
filter_subject: Optional[str] = None
182181
external: Optional[ExternalStream] = None
183182

184183
@classmethod
185184
def from_response(cls, resp: Dict[str, Any]):
186185
cls._convert(resp, 'external', ExternalStream)
186+
cls._convert_rfc3339(resp, 'opt_start_time')
187187
return super().from_response(resp)
188188

189+
def as_dict(self) -> Dict[str, object]:
190+
result = super().as_dict()
191+
if self.opt_start_time is not None:
192+
result['opt_start_time'] = self._to_rfc3339(self.opt_start_time)
193+
return result
194+
189195

190196
@dataclass
191197
class StreamSourceInfo(Base):

0 commit comments

Comments
 (0)