diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 040e3343..42126836 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -77,7 +77,7 @@ jobs: - run: | mk python-release owner=vkottler \ - repo=runtimepy version=5.3.0 + repo=runtimepy version=5.3.1 if: | matrix.python-version == '3.12' && matrix.system == 'ubuntu-latest' diff --git a/README.md b/README.md index 1fabc5fa..f870dec0 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ===================================== generator=datazen version=3.1.4 - hash=5d2077f589ab71dc3657c502813d4784 + hash=80ff32f18958cf12959d97ebc77f4c32 ===================================== --> -# runtimepy ([5.3.0](https://pypi.org/project/runtimepy/)) +# runtimepy ([5.3.1](https://pypi.org/project/runtimepy/)) [![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/) ![Build Status](https://github.com/vkottler/runtimepy/workflows/Python%20Package/badge.svg) diff --git a/local/variables/package.yaml b/local/variables/package.yaml index 4ee07437..4a0244cc 100644 --- a/local/variables/package.yaml +++ b/local/variables/package.yaml @@ -1,5 +1,5 @@ --- major: 5 minor: 3 -patch: 0 +patch: 1 entry: runtimepy diff --git a/pyproject.toml b/pyproject.toml index f0cd5525..24f701e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__" [project] name = "runtimepy" -version = "5.3.0" +version = "5.3.1" description = "A framework for implementing Python services." readme = "README.md" requires-python = ">=3.11" diff --git a/runtimepy/__init__.py b/runtimepy/__init__.py index 238ad3b5..34ee28fd 100644 --- a/runtimepy/__init__.py +++ b/runtimepy/__init__.py @@ -1,7 +1,7 @@ # ===================================== # generator=datazen # version=3.1.4 -# hash=ec0d70a1963b4f2d02aa421f4d961643 +# hash=231380c332c2ef6a1d5009c0a20aed5c # ===================================== """ @@ -10,7 +10,7 @@ DESCRIPTION = "A framework for implementing Python services." PKG_NAME = "runtimepy" -VERSION = "5.3.0" +VERSION = "5.3.1" # runtimepy-specific content. METRICS_NAME = "metrics" diff --git a/runtimepy/primitives/serializable/base.py b/runtimepy/primitives/serializable/base.py index b846f941..839493b5 100644 --- a/runtimepy/primitives/serializable/base.py +++ b/runtimepy/primitives/serializable/base.py @@ -105,25 +105,28 @@ def to_stream(self, stream: _BinaryIO) -> int: return result @abstractmethod - def update(self, data: bytes) -> int: + def update(self, data: bytes, timestamp_ns: int = None) -> int: """Update this serializable from a bytes instance.""" - def update_str(self, data: str) -> int: + def update_str(self, data: str, timestamp_ns: int = None) -> int: """Update this serializable from string data.""" - return self.update(data.encode(encoding=DEFAULT_ENCODING)) - def _from_stream(self, stream: _BinaryIO) -> int: + return self.update( + data.encode(encoding=DEFAULT_ENCODING), timestamp_ns=timestamp_ns + ) + + def _from_stream(self, stream: _BinaryIO, timestamp_ns: int = None) -> int: """Update just this instance from a stream.""" - return self.update(stream.read(self.size)) + return self.update(stream.read(self.size), timestamp_ns=timestamp_ns) - def from_stream(self, stream: _BinaryIO) -> int: + def from_stream(self, stream: _BinaryIO, timestamp_ns: int = None) -> int: """Update this serializable from a stream.""" - result = self._from_stream(stream) + result = self._from_stream(stream, timestamp_ns=timestamp_ns) if self.chain is not None: - result += self.chain.from_stream(stream) + result += self.chain.from_stream(stream, timestamp_ns=timestamp_ns) return result diff --git a/runtimepy/primitives/serializable/fixed.py b/runtimepy/primitives/serializable/fixed.py index 7a85d129..6f24f635 100644 --- a/runtimepy/primitives/serializable/fixed.py +++ b/runtimepy/primitives/serializable/fixed.py @@ -31,9 +31,11 @@ def __bytes__(self) -> bytes: """Get this serializable as a bytes instance.""" return self.data - def update(self, data: bytes) -> int: + def update(self, data: bytes, timestamp_ns: int = None) -> int: """Update this serializable from a bytes instance.""" + del timestamp_ns + self.data = data self.size = len(self.data) return self.size diff --git a/runtimepy/primitives/serializable/prefixed.py b/runtimepy/primitives/serializable/prefixed.py index aec1e297..115204c2 100644 --- a/runtimepy/primitives/serializable/prefixed.py +++ b/runtimepy/primitives/serializable/prefixed.py @@ -44,10 +44,10 @@ def __str__(self) -> str: """Get this chunk as a string.""" return str(self.chunk) - def update(self, data: bytes) -> int: + def update(self, data: bytes, timestamp_ns: int = None) -> int: """Update this serializable from a bytes instance.""" - size = self.chunk.update(data) + size = self.chunk.update(data, timestamp_ns=timestamp_ns) self.prefix.value = size return self._update_size() @@ -73,13 +73,14 @@ def __bytes__(self) -> bytes: self.chunk ) - def _from_stream(self, stream: _BinaryIO) -> int: + def _from_stream(self, stream: _BinaryIO, timestamp_ns: int = None) -> int: """Update just this instance from a stream.""" self.chunk.update( stream.read( self.prefix.from_stream(stream, byte_order=self.byte_order) - ) + ), + timestamp_ns=timestamp_ns, ) return self._update_size()