use of com.bakdata.quick.common.api.model.manager.GatewaySchema in project quick by bakdata.
the class KafkaTopicService method getQuickSchemas.
private Single<Optional<QuickSchemas>> getQuickSchemas(final GatewaySchema gatewaySchema) {
if (gatewaySchema == null) {
return Single.just(Optional.empty());
}
// make sure the gateway exists
return this.gatewayService.getGateway(gatewaySchema.getGateway()).flatMap(ignored -> this.gatewayClient.getWriteSchema(gatewaySchema.getGateway(), gatewaySchema.getType())).map(schemaResponse -> {
final String graphQLSchema = schemaResponse.getSchema();
final Schema avroSchema = graphQLToAvroConverter.convertToSchema(graphQLSchema);
return Optional.of(new QuickSchemas(graphQLSchema, avroSchema));
});
}
use of com.bakdata.quick.common.api.model.manager.GatewaySchema in project quick by bakdata.
the class TopicControllerTest method testCreateTopicWhenQueryIsNotDefined.
@Test
void testCreateTopicWhenQueryIsNotDefined() {
when(this.service.createTopic(anyString(), any(), any(), any())).thenReturn(Completable.complete());
final TopicCreationData creationData = new TopicCreationData(TopicWriteType.MUTABLE, null, new GatewaySchema("test", "test"), null);
this.client.toBlocking().exchange(POST(baseUri, creationData));
verify(this.service).createTopic(NAME, QuickTopicType.LONG, QuickTopicType.SCHEMA, creationData);
}
use of com.bakdata.quick.common.api.model.manager.GatewaySchema in project quick by bakdata.
the class KubernetesGatewayService method getGatewayWriteSchema.
@Override
public Single<SchemaData> getGatewayWriteSchema(final String name, final String type, final SchemaFormat format) {
final GatewaySchema gatewaySchema = new GatewaySchema(name, type);
// make sure the gateway exists
final Completable exists = this.kubernetesManagerClient.checkDeploymentExistence(ResourcePrefix.GATEWAY, name);
final Action logAccess = () -> log.debug("Retrieve schema in '{}' gateway for type '{}' in '{}'", name, type, format.getName());
final Single<SchemaData> fetchSchema = this.gatewayClient.getWriteSchema(gatewaySchema.getGateway(), gatewaySchema.getType()).map(response -> {
String schema = response.getSchema();
if (format == SchemaFormat.AVRO) {
schema = graphQLToAvroConverter.convertToSchema(schema).toString();
}
return new SchemaData(schema);
});
return exists.doOnComplete(logAccess).andThen(fetchSchema);
}
Aggregations