io.quarkus.pulsar.SchemaProviderRecorder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-messaging-pulsar Show documentation
Show all versions of quarkus-messaging-pulsar Show documentation
Connect to Apache Pulsar with Reactive Messaging
package io.quarkus.pulsar;
import java.nio.ByteBuffer;
import java.util.function.Supplier;
import org.apache.pulsar.client.api.Schema;
import io.quarkus.pulsar.schema.BufferSchema;
import io.quarkus.pulsar.schema.JsonArraySchema;
import io.quarkus.pulsar.schema.JsonObjectSchema;
import io.quarkus.pulsar.schema.ObjectMapperSchema;
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.annotations.Recorder;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
@Recorder
public class SchemaProviderRecorder {
public Supplier> createJsonSchema(Class type) {
return new Supplier>() {
@Override
public Schema get() {
return Schema.JSON(type);
}
};
};
public Supplier> createAvroSchema(Class type) {
return new Supplier>() {
@Override
public Schema get() {
return Schema.AVRO(type);
}
};
};
public Supplier> createProtoBufSchema(Class> type) {
return new Supplier>() {
@Override
public Schema> get() {
return Schema.PROTOBUF((Class) type);
}
};
}
public RuntimeValue> createObjectMapperSchema(Class type) {
return new RuntimeValue<>(ObjectMapperSchema.of(type));
}
public RuntimeValue> createBufferSchema() {
return new RuntimeValue<>(BufferSchema.INSTANCE);
}
public RuntimeValue> createJsonObjectSchema() {
return new RuntimeValue<>(JsonObjectSchema.INSTANCE);
}
public RuntimeValue> createJsonArraySchema() {
return new RuntimeValue<>(JsonArraySchema.INSTANCE);
}
public RuntimeValue> createByteBufferSchema() {
return new RuntimeValue<>(Schema.BYTEBUFFER);
}
}