This is an automated email from the ASF dual-hosted git repository.
duhengforever pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-python.git
The following commit(s) were added to refs/heads/master by this push:
new 71363a7 support trace (#136)
71363a7 is described below
commit 71363a7d50cbdc50e2fcd62e2fd2ccc02018c0fb
Author: yuz10 <[email protected]>
AuthorDate: Wed Mar 20 20:22:20 2024 +0800
support trace (#136)
---
rocketmq/client.py | 11 ++++++++++-
rocketmq/ffi.py | 10 ++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/rocketmq/client.py b/rocketmq/client.py
index 88ae128..fecac9c 100644
--- a/rocketmq/client.py
+++ b/rocketmq/client.py
@@ -23,7 +23,7 @@ from collections import namedtuple
from .ffi import (
dll, _CSendResult, MSG_CALLBACK_FUNC, MessageModel,
TRANSACTION_CHECK_CALLBACK,
- LOCAL_TRANSACTION_EXECUTE_CALLBACK
+ LOCAL_TRANSACTION_EXECUTE_CALLBACK, TraceModel
)
from .exceptions import (
ffi_check, NullPointerException,
@@ -259,6 +259,9 @@ class Producer(object):
def set_max_message_size(self, max_size):
ffi_check(dll.SetProducerMaxMessageSize(self._handle, max_size))
+ def set_message_trace(self, message_trace):
+ ffi_check(dll.SetProducerMessageTrace(self._handle, message_trace and
TraceModel.OPEN or TraceModel.CLOSE))
+
def start(self):
ffi_check(dll.StartProducer(self._handle))
@@ -311,6 +314,9 @@ class TransactionMQProducer(Producer):
def set_name_server_address(self, addr):
ffi_check(dll.SetProducerNameServerAddress(self._handle,
_to_bytes(addr)))
+ def set_message_trace(self, message_trace):
+ ffi_check(dll.SetProducerMessageTrace(self._handle, message_trace and
TraceModel.OPEN or TraceModel.CLOSE))
+
def start(self):
ffi_check(dll.StartProducer(self._handle))
@@ -437,3 +443,6 @@ class PushConsumer(object):
def set_instance_name(self, name):
ffi_check(dll.SetPushConsumerInstanceName(self._handle,
_to_bytes(name)))
+
+ def set_message_trace(self, message_trace):
+ ffi_check(dll.SetPushConsumerMessageTrace(self._handle, message_trace
and TraceModel.OPEN or TraceModel.CLOSE))
diff --git a/rocketmq/ffi.py b/rocketmq/ffi.py
index 21a01df..b4f6a11 100644
--- a/rocketmq/ffi.py
+++ b/rocketmq/ffi.py
@@ -81,6 +81,11 @@ class MessageModel(CtypesEnum):
CLUSTERING = 1
+class TraceModel(CtypesEnum):
+ OPEN = 0
+ CLOSE = 1
+
+
class _CSendResult(Structure):
_fields_ = [
('sendStatus', c_int),
@@ -200,6 +205,8 @@ dll.SetProducerCompressLevel.argtypes = [c_void_p, c_int]
dll.SetProducerCompressLevel.restype = _CStatus
dll.SetProducerMaxMessageSize.argtypes = [c_void_p, c_int]
dll.SetProducerMaxMessageSize.restype = _CStatus
+dll.SetProducerMessageTrace.argtypes = [c_void_p, TraceModel]
+dll.SetProducerMessageTrace.restype = _CStatus
dll.SendMessageSync.argtypes = [c_void_p, c_void_p, POINTER(_CSendResult)]
dll.SendMessageSync.restype = _CStatus
dll.SendMessageOneway.argtypes = [c_void_p, c_void_p]
@@ -261,6 +268,9 @@ dll.SetPushConsumerLogLevel.argtypes = [c_void_p,
_CLogLevel]
dll.SetPushConsumerLogLevel.restype = _CStatus
dll.SetPushConsumerMessageModel.argtypes = [c_void_p, MessageModel]
dll.SetPushConsumerMessageModel.restype = _CStatus
+dll.SetPushConsumerLogLevel.restype = _CStatus
+dll.SetPushConsumerMessageTrace.argtypes = [c_void_p, TraceModel]
+dll.SetPushConsumerMessageTrace.restype = _CStatus
# Misc
dll.GetLatestErrorMessage.argtypes = []