/** * Returns A {@link PTransform} that writes UTF-8 encoded strings to a Google Cloud Pub/Sub * stream. */ public static Write<String> writeStrings() { return PubsubIO.<String>write().withFormatFn(new FormatPayloadAsUtf8()); }
/** Returns A {@link PTransform} that writes to a Google Cloud Pub/Sub stream. */ public static Write<PubsubMessage> writeMessages() { return PubsubIO.<PubsubMessage>write().withFormatFn(new IdentityMessageFn()); }
/** * Returns A {@link PTransform} that writes binary encoded Avro messages of a given type to a * Google Cloud Pub/Sub stream. */ public static <T> Write<T> writeAvros(Class<T> clazz) { // TODO: Like in readAvros(), stop using AvroCoder and instead format the payload directly. return PubsubIO.<T>write().withFormatFn(new FormatPayloadUsingCoder<>(AvroCoder.of(clazz))); }
/** * Returns A {@link PTransform} that writes binary encoded protobuf messages of a given type to a * Google Cloud Pub/Sub stream. */ public static <T extends Message> Write<T> writeProtos(Class<T> messageClass) { // TODO: Like in readProtos(), stop using ProtoCoder and instead format the payload directly. return PubsubIO.<T>write() .withFormatFn(new FormatPayloadUsingCoder<>(ProtoCoder.of(messageClass))); }