class documentation
class ProtobufNativeSchema(Schema): (source)
Constructor: ProtobufNativeSchema(record_cls)
Schema for protobuf messages using the native protobuf binary encoding.
The schema definition is stored as a JSON-encoded ProtobufNativeSchemaData (fileDescriptorSet, rootMessageTypeName, rootFileDescriptorName), which is compatible with the Java client's ProtobufNativeSchema.
Example
import pulsar from pulsar.schema import ProtobufNativeSchema from my_proto_pb2 import MyMessage client = pulsar.Client('pulsar://localhost:6650') schema = ProtobufNativeSchema(MyMessage) producer = client.create_producer('my-topic', schema=schema) consumer = client.subscribe('my-topic', 'my-sub', schema=schema) message = MyMessage() message.field = 'value' producer.send(message) received = consumer.receive(timeout_millis=5000) typed_value = received.value() consumer.acknowledge(received) assert isinstance(typed_value, MyMessage) assert typed_value.field == 'value' consumer.close() producer.close() client.close()
| Parameters | |
| record | A generated protobuf message class (subclass of google.protobuf.message.Message). |
| Method | __init__ |
Undocumented |
| Method | __str__ |
Undocumented |
| Method | decode |
Undocumented |
| Method | encode |
Undocumented |
Inherited from Schema:
| Method | attach |
Undocumented |
| Method | decode |
Undocumented |
| Method | schema |
Undocumented |
| Method | _validate |
Undocumented |
| Instance Variable | _client |
Undocumented |
| Instance Variable | _record |
Undocumented |
| Instance Variable | _schema |
Undocumented |