MessageSet.build constructor
MessageSet.build(
- ProduceEnvelope envelope
Builds new message set for publishing.
Implementation
factory MessageSet.build(ProduceEnvelope envelope) {
if (envelope.compression == KafkaCompression.none) {
return MessageSet._(envelope.messages.asMap());
} else {
if (envelope.compression == KafkaCompression.snappy) throw ArgumentError('Snappy compression is not supported yet by the client.');
var codec = GZipCodec();
var innerEnvelope = ProduceEnvelope(envelope.topicName, envelope.partitionId, envelope.messages);
var innerMessageSet = MessageSet.build(innerEnvelope);
var value = codec.encode(innerMessageSet.toBytes());
var attrs = MessageAttributes(KafkaCompression.gzip);
return new MessageSet._({0: Message(value, attributes: attrs)});
}
}