Skip to content

Commit

Permalink
feat(document): restructure the project and move document stuff to a …
Browse files Browse the repository at this point in the history
…different package (#3149)

* refactor: move document stuff to a different module

---------

Co-authored-by: Jonathan Roques <[email protected]>
  • Loading branch information
chillleader and johnBgood committed Aug 29, 2024
1 parent 1ed03da commit 5299575
Show file tree
Hide file tree
Showing 47 changed files with 258 additions and 211 deletions.
5 changes: 5 additions & 0 deletions connector-runtime/connector-runtime-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<artifactId>connector-core</artifactId>
</dependency>

<dependency>
<groupId>io.camunda.connector</groupId>
<artifactId>connector-document</artifactId>
</dependency>

<!-- Jackson dependencies defined as provided in the Connector SDK Core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.EvictingQueue;
import io.camunda.connector.api.document.DocumentFactory;
import io.camunda.connector.api.inbound.InboundConnectorContext;
import io.camunda.connector.api.inbound.InboundConnectorExecutable;
import io.camunda.connector.api.inbound.InboundIntermediateConnectorContext;
import io.camunda.connector.api.validation.ValidationProvider;
import io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler;
import io.camunda.connector.runtime.core.inbound.details.InboundConnectorDetails.ValidInboundConnectorDetails;
import io.camunda.connector.runtime.core.secret.SecretProviderAggregator;
import io.camunda.document.factory.DocumentFactory;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.function.Consumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.EvictingQueue;
import io.camunda.connector.api.document.Document;
import io.camunda.connector.api.document.DocumentFactory;
import io.camunda.connector.api.document.store.DocumentCreationRequest;
import io.camunda.connector.api.inbound.Activity;
import io.camunda.connector.api.inbound.CorrelationResult;
import io.camunda.connector.api.inbound.Health;
Expand All @@ -31,11 +28,14 @@
import io.camunda.connector.api.validation.ValidationProvider;
import io.camunda.connector.feel.FeelEngineWrapperException;
import io.camunda.connector.runtime.core.AbstractConnectorContext;
import io.camunda.connector.runtime.core.document.DocumentFactoryImpl;
import io.camunda.connector.runtime.core.document.InMemoryDocumentStore;
import io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler;
import io.camunda.connector.runtime.core.inbound.details.InboundConnectorDetails;
import io.camunda.connector.runtime.core.inbound.details.InboundConnectorDetails.ValidInboundConnectorDetails;
import io.camunda.document.Document;
import io.camunda.document.factory.DocumentFactory;
import io.camunda.document.factory.DocumentFactoryImpl;
import io.camunda.document.store.DocumentCreationRequest;
import io.camunda.document.store.InMemoryDocumentStore;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand All @@ -56,12 +56,10 @@ public class InboundConnectorContextImpl extends AbstractConnectorContext
private final ObjectMapper objectMapper;

private final Consumer<Throwable> cancellationCallback;

private Health health = Health.unknown();

private final EvictingQueue<Activity> logs;

private final DocumentFactory documentFactory;
private Health health = Health.unknown();
private Map<String, Object> propertiesWithSecrets;

public InboundConnectorContextImpl(
SecretProvider secretProvider,
Expand Down Expand Up @@ -95,7 +93,7 @@ public InboundConnectorContextImpl(
this(
secretProvider,
validationProvider,
new DocumentFactoryImpl(new InMemoryDocumentStore()),
new DocumentFactoryImpl(InMemoryDocumentStore.INSTANCE),
connectorDetails,
correlationHandler,
cancellationCallback,
Expand Down Expand Up @@ -182,8 +180,6 @@ public Document createDocument(DocumentCreationRequest request) {
return documentFactory.create(request);
}

private Map<String, Object> propertiesWithSecrets;

private Map<String, Object> getPropertiesWithSecrets(Map<String, Object> properties) {
if (propertiesWithSecrets == null) {
propertiesWithSecrets =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package io.camunda.connector.runtime.core.inbound;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.connector.api.document.Document;
import io.camunda.connector.api.document.store.DocumentCreationRequest;
import io.camunda.connector.api.inbound.Activity;
import io.camunda.connector.api.inbound.CorrelationResult;
import io.camunda.connector.api.inbound.Health;
Expand All @@ -29,6 +27,8 @@
import io.camunda.connector.api.validation.ValidationProvider;
import io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler;
import io.camunda.connector.runtime.core.inbound.correlation.MessageCorrelationPoint.BoundaryEventCorrelationPoint;
import io.camunda.document.Document;
import io.camunda.document.store.DocumentCreationRequest;
import io.camunda.operate.model.FlowNodeInstance;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.camunda.connector.runtime.core.outbound;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.connector.api.document.DocumentFactory;
import io.camunda.connector.api.error.ConnectorException;
import io.camunda.connector.api.error.ConnectorRetryException;
import io.camunda.connector.api.outbound.OutboundConnectorFunction;
Expand All @@ -34,6 +33,7 @@
import io.camunda.connector.runtime.core.outbound.ErrorExpressionJobContext.ErrorExpressionJob;
import io.camunda.connector.runtime.core.secret.SecretProviderAggregator;
import io.camunda.connector.runtime.core.secret.SecretProviderDiscovery;
import io.camunda.document.factory.DocumentFactory;
import io.camunda.zeebe.client.api.command.FinalCommandStep;
import io.camunda.zeebe.client.api.response.ActivatedJob;
import io.camunda.zeebe.client.api.response.CompleteJobResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.*;
import io.camunda.connector.api.document.Document;
import io.camunda.connector.api.document.DocumentFactory;
import io.camunda.connector.api.document.store.DocumentCreationRequest;
import io.camunda.connector.api.error.ConnectorException;
import io.camunda.connector.api.outbound.JobContext;
import io.camunda.connector.api.outbound.OutboundConnectorContext;
import io.camunda.connector.api.secret.SecretProvider;
import io.camunda.connector.api.validation.ValidationProvider;
import io.camunda.connector.runtime.core.AbstractConnectorContext;
import io.camunda.connector.runtime.core.document.DocumentFactoryImpl;
import io.camunda.connector.runtime.core.document.InMemoryDocumentStore;
import io.camunda.document.Document;
import io.camunda.document.factory.DocumentFactory;
import io.camunda.document.factory.DocumentFactoryImpl;
import io.camunda.document.store.DocumentCreationRequest;
import io.camunda.document.store.InMemoryDocumentStore;
import io.camunda.zeebe.client.api.response.ActivatedJob;
import java.util.Objects;
import org.slf4j.Logger;
Expand All @@ -50,9 +50,8 @@ public class JobHandlerContext extends AbstractConnectorContext

private final ObjectMapper objectMapper;
private final JobContext jobContext;
private String jsonWithSecrets = null;

private final DocumentFactory documentFactory;
private String jsonWithSecrets = null;

public JobHandlerContext(
final ActivatedJob job,
Expand All @@ -76,7 +75,7 @@ public JobHandlerContext(
job,
secretProvider,
validationProvider,
new DocumentFactoryImpl(new InMemoryDocumentStore()),
new DocumentFactoryImpl(InMemoryDocumentStore.INSTANCE),
objectMapper);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.EvictingQueue;
import io.camunda.connector.api.document.DocumentFactory;
import io.camunda.connector.api.inbound.InboundConnectorContext;
import io.camunda.connector.api.inbound.InboundConnectorExecutable;
import io.camunda.connector.api.inbound.InboundIntermediateConnectorContext;
import io.camunda.connector.api.validation.ValidationProvider;
import io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler;
import io.camunda.connector.runtime.core.inbound.details.InboundConnectorDetails.ValidInboundConnectorDetails;
import io.camunda.connector.runtime.core.secret.SecretProviderAggregator;
import io.camunda.document.factory.DocumentFactory;
import java.util.function.Consumer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.camunda.connector.runtime.inbound;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.connector.api.document.DocumentFactory;
import io.camunda.connector.api.validation.ValidationProvider;
import io.camunda.connector.feel.FeelEngineWrapper;
import io.camunda.connector.runtime.core.inbound.DefaultInboundConnectorContextFactory;
Expand All @@ -39,6 +38,7 @@
import io.camunda.connector.runtime.inbound.state.ProcessStateStore;
import io.camunda.connector.runtime.inbound.state.TenantAwareProcessStateStoreImpl;
import io.camunda.connector.runtime.inbound.webhook.WebhookConnectorRegistry;
import io.camunda.document.factory.DocumentFactory;
import io.camunda.operate.CamundaOperateClient;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.spring.client.metrics.MetricsRecorder;
Expand All @@ -59,6 +59,11 @@ public class InboundConnectorRuntimeConfiguration {
@Value("${camunda.connector.inbound.message.ttl:PT1H}")
private Duration messageTtl;

@Bean
public static InboundConnectorBeanDefinitionProcessor inboundConnectorBeanDefinitionProcessor() {
return new InboundConnectorBeanDefinitionProcessor();
}

@Bean
public ProcessElementContextFactory processElementContextFactory(
ObjectMapper objectMapper,
Expand All @@ -78,11 +83,6 @@ public InboundCorrelationHandler inboundCorrelationHandler(
zeebeClient, feelEngine, metricsRecorder, elementContextFactory, messageTtl);
}

@Bean
public static InboundConnectorBeanDefinitionProcessor inboundConnectorBeanDefinitionProcessor() {
return new InboundConnectorBeanDefinitionProcessor();
}

@Bean
public InboundConnectorContextFactory springInboundConnectorContextFactory(
ObjectMapper mapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
package io.camunda.connector.runtime.outbound;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.connector.api.document.DocumentFactory;
import io.camunda.connector.api.validation.ValidationProvider;
import io.camunda.connector.runtime.core.document.DocumentFactoryImpl;
import io.camunda.connector.runtime.core.document.InMemoryDocumentStore;
import io.camunda.connector.runtime.core.outbound.DefaultOutboundConnectorFactory;
import io.camunda.connector.runtime.core.outbound.OutboundConnectorDiscovery;
import io.camunda.connector.runtime.core.outbound.OutboundConnectorFactory;
import io.camunda.connector.runtime.core.secret.SecretProviderAggregator;
import io.camunda.connector.runtime.outbound.lifecycle.OutboundConnectorAnnotationProcessor;
import io.camunda.connector.runtime.outbound.lifecycle.OutboundConnectorManager;
import io.camunda.document.factory.DocumentFactory;
import io.camunda.document.factory.DocumentFactoryImpl;
import io.camunda.document.store.InMemoryDocumentStore;
import io.camunda.zeebe.spring.client.jobhandling.CommandExceptionHandlingStrategy;
import io.camunda.zeebe.spring.client.jobhandling.JobWorkerManager;
import io.camunda.zeebe.spring.client.metrics.MetricsRecorder;
Expand All @@ -45,7 +45,7 @@ public OutboundConnectorFactory outboundConnectorFactory() {

@Bean
public DocumentFactory documentFactory() {
return new DocumentFactoryImpl(new InMemoryDocumentStore());
return new DocumentFactoryImpl(InMemoryDocumentStore.INSTANCE);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.camunda.connector.runtime.outbound.jobhandling;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.connector.api.document.DocumentFactory;
import io.camunda.connector.api.outbound.OutboundConnectorFunction;
import io.camunda.connector.api.validation.ValidationProvider;
import io.camunda.connector.runtime.core.config.OutboundConnectorConfiguration;
Expand All @@ -27,6 +26,7 @@
import io.camunda.connector.runtime.core.secret.SecretProviderAggregator;
import io.camunda.connector.runtime.metrics.ConnectorMetrics;
import io.camunda.connector.runtime.metrics.ConnectorMetrics.Outbound;
import io.camunda.document.factory.DocumentFactory;
import io.camunda.zeebe.client.api.command.FinalCommandStep;
import io.camunda.zeebe.client.api.response.ActivatedJob;
import io.camunda.zeebe.client.api.worker.JobClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
package io.camunda.connector.runtime.outbound.lifecycle;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.connector.api.document.DocumentFactory;
import io.camunda.connector.api.outbound.OutboundConnectorFunction;
import io.camunda.connector.api.validation.ValidationProvider;
import io.camunda.connector.runtime.core.config.OutboundConnectorConfiguration;
import io.camunda.connector.runtime.core.outbound.OutboundConnectorFactory;
import io.camunda.connector.runtime.core.secret.SecretProviderAggregator;
import io.camunda.connector.runtime.outbound.jobhandling.SpringConnectorJobHandler;
import io.camunda.document.factory.DocumentFactory;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.worker.JobHandler;
import io.camunda.zeebe.spring.client.annotation.value.ZeebeWorkerValue;
Expand Down
5 changes: 5 additions & 0 deletions connector-sdk/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
<artifactId>jackson-datatype-jdk8</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.camunda.connector</groupId>
<artifactId>jackson-datatype-document</artifactId>
<version>8.6.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package io.camunda.connector.api.inbound;

import io.camunda.connector.api.document.Document;
import io.camunda.connector.api.document.store.DocumentCreationRequest;
import io.camunda.document.Document;
import io.camunda.document.store.DocumentCreationRequest;
import java.util.Map;

/**
Expand Down Expand Up @@ -56,7 +56,7 @@ public interface InboundConnectorContext {

/**
* Low-level properties access method. Allows to perform custom deserialization. For a simpler
* property access, consider using {@link #bindProperties(Class)} (Class)}.
* property access, consider using {@link #bindProperties(Class)}.
*
* <p>Note: this method doesn't perform validation or FEEl expression evaluation. Secret
* replacement is performed using the {@link io.camunda.connector.api.secret.SecretProvider}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,34 @@
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import io.camunda.connector.document.annotation.jackson.JacksonModuleDocument;
import io.camunda.connector.document.annotation.jackson.JacksonModuleDocument.DocumentModuleSettings;
import io.camunda.connector.feel.jackson.JacksonModuleFeelFunction;
import io.camunda.document.factory.DocumentFactoryImpl;
import io.camunda.document.store.InMemoryDocumentStore;

/** Default ObjectMapper supplier to be used by the connector runtime. */
public class ConnectorsObjectMapperSupplier {

private ConnectorsObjectMapperSupplier() {}

public static ObjectMapper DEFAULT_MAPPER =
JsonMapper.builder()
.addModules(new JacksonModuleFeelFunction(), new Jdk8Module(), new JavaTimeModule())
.addModules(
new JacksonModuleFeelFunction(),
new JacksonModuleDocument(
new DocumentFactoryImpl(InMemoryDocumentStore.INSTANCE),
null,
DocumentModuleSettings.create()),
new Jdk8Module(),
new JavaTimeModule())
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS)
.build();

private ConnectorsObjectMapperSupplier() {}

public static ObjectMapper getCopy() {
return DEFAULT_MAPPER.copy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package io.camunda.connector.api.outbound;

import io.camunda.connector.api.document.Document;
import io.camunda.connector.api.document.store.DocumentCreationRequest;
import io.camunda.document.Document;
import io.camunda.document.store.DocumentCreationRequest;

/**
* The context object provided to a connector function. The context allows to fetch information
Expand Down
19 changes: 19 additions & 0 deletions connector-sdk/document/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.camunda.connector</groupId>
<artifactId>connector-sdk-parent</artifactId>
<relativePath>../pom.xml</relativePath>
<version>8.6.0-SNAPSHOT</version>
</parent>

<name>connector-document</name>
<description>Camunda Connector Document</description>
<artifactId>connector-document</artifactId>
<packaging>jar</packaging>



</project>
Loading

0 comments on commit 5299575

Please sign in to comment.