Beispiel #1
0
 async def set(self, path, data, version):
     # type: (str, str, int) -> protocol.SetDataResponse
     path = self.normalize_path(path)
     response = await self.send(
         protocol.SetDataRequest(path=path, data=data, version=version)
     )
     return response.stat
Beispiel #2
0
    async def set_data(self, path, data, force=False):
        """
        Set data to znode without needing to handle version.

        :param str path: Path of znode

        :param data: Data to be stored at znode
        :type data: bytes or str

        :param bool force: True for ignoring data version. False for using
            version from stat cache.

        :raises aiozk.exc.NoNode: Raised if znode does not exist

        :raises aiozk.exc.BadVersion: Raised if force parameter is False and
            only if supplied version from stat cache does not match the actual
            version of znode data.
        """
        path = self.normalize_path(path)

        if not force and path in self.stat_cache:
            version = self.stat_cache[path].version
        else:
            version = -1

        await self.send(
            protocol.SetDataRequest(path=path, data=data, version=version))
Beispiel #3
0
    async def set(self, path, data, version):
        """
        Set data to znode. Prefer using .set_data than this method unless you
        have to control the concurrency.

        :param str path: Path of znode

        :param data: Data to store at znode
        :type data: str or bytes

        :param int version: Version of znode data to be modified.

        :return: Response stat
        :rtype: aiozk.protocol.stat.Stat

        :raises aiozk.exc.NoNode: Raised if znode does not exist

        :raises aiozk.exc.BadVersion: Raised if version does not match the
            actual version of the data. The update failed.
        """
        # type: (str, str, int) -> protocol.SetDataResponse
        path = self.normalize_path(path)
        response = await self.send(
            protocol.SetDataRequest(path=path, data=data, version=version))
        return response.stat
Beispiel #4
0
    async def set_data(self, path, data, force=False):
        path = self.normalize_path(path)

        if not force and path in self.stat_cache:
            version = self.stat_cache[path].version
        else:
            version = -1

        await self.send(protocol.SetDataRequest(path=path, data=data, version=version))
Beispiel #5
0
    def set_data(self, path, data, version=-1):
        """
        Set data to znode

        :param str path: Znode path

        :param data: Data to store in node
        :type data: str or bytes

        :param int version: Current version of node

        :return: None
        """
        path = self.client.normalize_path(path)

        self.request.add(
            protocol.SetDataRequest(path=path, data=data, version=version))
Beispiel #6
0
    def set_data(self, path, data, version=-1):
        path = self.client.normalize_path(path)

        self.request.add(
            protocol.SetDataRequest(path=path, data=data, version=version))