pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mme...@apache.org
Subject [pulsar] branch master updated: [Issue 3926][functions] Add delete counter in python functions state_context (#3930)
Date Fri, 29 Mar 2019 16:08:48 GMT
This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 08c97f7  [Issue 3926][functions] Add delete counter in python functions state_context
(#3930)
08c97f7 is described below

commit 08c97f703a5bf1de2330c4c6ae00a2fe170ed692
Author: Laurent Chriqui <40354867+laurent-chriqui@users.noreply.github.com>
AuthorDate: Fri Mar 29 17:08:42 2019 +0100

    [Issue 3926][functions] Add delete counter in python functions state_context (#3930)
    
    * add delete_counter in python functions state_context
    
    * Update contextimpl.py
    
    Matched the name of the stub method to the one in ContextImpl
---
 pulsar-client-cpp/python/pulsar/functions/context.py       | 5 +++++
 pulsar-functions/instance/src/main/python/contextimpl.py   | 3 +++
 pulsar-functions/instance/src/main/python/state_context.py | 7 +++++--
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/pulsar-client-cpp/python/pulsar/functions/context.py b/pulsar-client-cpp/python/pulsar/functions/context.py
index bad6f35..169ec76 100644
--- a/pulsar-client-cpp/python/pulsar/functions/context.py
+++ b/pulsar-client-cpp/python/pulsar/functions/context.py
@@ -155,6 +155,11 @@ class Context(object):
     pass
 
   @abstractmethod
+  def del_counter(self, key):
+    """delete the counter of a given key in the managed state"""
+    pass
+
+  @abstractmethod
   def put_state(self, key, value):
     """update the value of a given key in the managed state"""
     pass
diff --git a/pulsar-functions/instance/src/main/python/contextimpl.py b/pulsar-functions/instance/src/main/python/contextimpl.py
index f3a9710..f19381b 100644
--- a/pulsar-functions/instance/src/main/python/contextimpl.py
+++ b/pulsar-functions/instance/src/main/python/contextimpl.py
@@ -215,6 +215,9 @@ class ContextImpl(pulsar.Context):
   def get_counter(self, key):
     return self.state_context.get_amount(key)
 
+  def del_counter(self, key):
+    return self.state_context.delete(key)
+
   def put_state(self, key, value):
     return self.state_context.put(key, value)
 
diff --git a/pulsar-functions/instance/src/main/python/state_context.py b/pulsar-functions/instance/src/main/python/state_context.py
index ef8bbf4..12ceac6 100644
--- a/pulsar-functions/instance/src/main/python/state_context.py
+++ b/pulsar-functions/instance/src/main/python/state_context.py
@@ -106,9 +106,9 @@ class BKManagedStateContext(StateContext):
 
     def __init__(self, state_storage_serviceurl, table_ns, table_name):
         client_settings = StorageClientSettings(
-          service_uri=state_storage_serviceurl)
+            service_uri=state_storage_serviceurl)
         admin_client = admin.client.Client(
-          storage_client_settings=client_settings)
+            storage_client_settings=client_settings)
         # create namespace and table if needed
         ns = admin_client.namespace(table_ns)
         try:
@@ -154,3 +154,6 @@ class BKManagedStateContext(StateContext):
 
     def put(self, key, value):
         return self.__table__.put_str(key, value)
+
+    def delete_key(self, key):
+        return self.__table__.delete_str(key)


Mime
View raw message