This is an automated email from the ASF dual-hosted git repository.
scarb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
The following commit(s) were added to refs/heads/master by this push:
new b4a47a93 [ISSUE #784] fix python client (#783)
b4a47a93 is described below
commit b4a47a933dd1839d770b02bc7c385673a7ba9954
Author: yuz10 <[email protected]>
AuthorDate: Thu Jul 4 23:04:02 2024 +0800
[ISSUE #784] fix python client (#783)
fix python client
---
python/rocketmq/signature.py | 6 +++++-
python/rocketmq/simple_subscription_settings.py | 15 ++++-----------
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/python/rocketmq/signature.py b/python/rocketmq/signature.py
index 3b507ded..ed39f9b7 100644
--- a/python/rocketmq/signature.py
+++ b/python/rocketmq/signature.py
@@ -38,6 +38,10 @@ class Signature:
__CREDENTIAL = "Credential"
__SIGNED_HEADERS = "SignedHeaders"
__SIGNATURE = "Signature"
+ try:
+ __CLIENT_VERSION = importlib.metadata.version("rocketmq")
+ except Exception:
+ __CLIENT_VERSION = "0.1.0"
@staticmethod
def sign(client_config: ClientConfig, client_id: str):
@@ -45,7 +49,7 @@ class Signature:
metadata = [
(Signature.__LANGUAGE_KEY, "PYTHON"),
(Signature.__PROTOCOL_VERSION, "v2"),
- (Signature.__CLIENT_VERSION_KEY,
importlib.metadata.version("rocketmq")),
+ (Signature.__CLIENT_VERSION_KEY, Signature.__CLIENT_VERSION),
(
Signature.__DATE_TIME_KEY,
date_time,
diff --git a/python/rocketmq/simple_subscription_settings.py
b/python/rocketmq/simple_subscription_settings.py
index 6d193008..2ee60089 100644
--- a/python/rocketmq/simple_subscription_settings.py
+++ b/python/rocketmq/simple_subscription_settings.py
@@ -16,7 +16,7 @@
from typing import Dict
from google.protobuf.duration_pb2 import Duration
-from rocketmq.filter_expression import ExpressionType
+from rocketmq.filter_expression import ExpressionType, FilterExpression
from rocketmq.log import logger
from rocketmq.protocol.definition_pb2 import \
FilterExpression as ProtoFilterExpression
@@ -30,13 +30,6 @@ from rocketmq.protocol.definition_pb2 import \
from .settings import ClientType, ClientTypeHelper, Settings
-# Assuming a simple representation of FilterExpression for the purpose of this
example
-class FilterExpression:
- def __init__(self, type, expression):
- self.Type = type
- self.Expression = expression
-
-
class SimpleSubscriptionSettings(Settings):
def __init__(self, clientId, endpoints, consumerGroup, requestTimeout,
longPollingTimeout,
@@ -60,12 +53,12 @@ class SimpleSubscriptionSettings(Settings):
subscriptionEntry = ProtoSubscriptionEntry()
filterExpression = ProtoFilterExpression()
- if value.type == ExpressionType.Tag:
+ if value.type.value == ExpressionType.Tag.value:
filterExpression.type = ProtoFilterType.TAG
- elif value.type == ExpressionType.Sql92:
+ elif value.type.value == ExpressionType.Sql92.value:
filterExpression.type = ProtoFilterType.SQL
else:
- logger.warn(f"[Bug] Unrecognized filter type={value.Type} for
simple consumer")
+ logger.warn(f"[Bug] Unrecognized filter type={value.type} for
simple consumer")
filterExpression.expression = value.expression
subscriptionEntry.topic.CopyFrom(topic)