You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/10/12 13:03:31 UTC
[GitHub] srkukarni closed pull request #2781: Added ability to specify
compression while publishing
srkukarni closed pull request #2781: Added ability to specify compression while publishing
URL: https://github.com/apache/pulsar/pull/2781
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/pulsar-client-cpp/python/pulsar/functions/context.py b/pulsar-client-cpp/python/pulsar/functions/context.py
index 2510bad47b..47e86f978f 100644
--- a/pulsar-client-cpp/python/pulsar/functions/context.py
+++ b/pulsar-client-cpp/python/pulsar/functions/context.py
@@ -104,7 +104,7 @@ def record_metric(self, metric_name, metric_value):
pass
@abstractmethod
- def publish(self, topic_name, message, serde_class_name="serde.IdentitySerDe", properties=None):
+ def publish(self, topic_name, message, serde_class_name="serde.IdentitySerDe", properties=None, compression_type=None):
"""Publishes message to topic_name by first serializing the message using serde_class_name serde
The message will have properties specified if any"""
pass
diff --git a/pulsar-functions/instance/src/main/python/contextimpl.py b/pulsar-functions/instance/src/main/python/contextimpl.py
index dcfec423bc..211bb18607 100644
--- a/pulsar-functions/instance/src/main/python/contextimpl.py
+++ b/pulsar-functions/instance/src/main/python/contextimpl.py
@@ -118,17 +118,21 @@ def get_output_topic(self):
def get_output_serde_class_name(self):
return self.instance_config.function_details.outputSerdeClassName
- def publish(self, topic_name, message, serde_class_name="serde.IdentitySerDe", properties=None):
+ def publish(self, topic_name, message, serde_class_name="serde.IdentitySerDe", properties=None, compression_type=None):
# Just make sure that user supplied values are properly typed
topic_name = str(topic_name)
serde_class_name = str(serde_class_name)
+ pulsar_compression_type = pulsar._pulsar.CompressionType.NONE
+ if compression_type is not None:
+ pulsar_compression_type = compression_type
if topic_name not in self.publish_producers:
self.publish_producers[topic_name] = self.pulsar_client.create_producer(
topic_name,
block_if_queue_full=True,
batching_enabled=True,
batching_max_publish_delay_ms=1,
- max_pending_messages=100000
+ max_pending_messages=100000,
+ compression_type=compression_type
)
if serde_class_name not in self.publish_serializers:
@@ -164,4 +168,4 @@ def get_metrics(self):
m.max = accumulated_metric.max
m.min = accumulated_metric.min
metrics.metrics[metric_name] = m
- return metrics
\ No newline at end of file
+ return metrics
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services