Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.appsmith.server.dtos;

import com.appsmith.server.domains.Plugin;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpHeaders;
import reactor.core.publisher.Mono;

@Data
@AllArgsConstructor
Expand All @@ -14,4 +16,5 @@ public class ExecuteActionMetaDTO {
String environmentId;
HttpHeaders headers;
boolean operateWithoutPermission = false;
Mono<Plugin> plugin;
Comment thread
ApekshaBhosale marked this conversation as resolved.
Outdated
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,36 @@ private Mono<ExecuteActionDTO> populateExecuteActionDTO(ExecuteActionDTO execute
@Override
public Mono<ActionExecutionResult> executeAction(
Flux<Part> partFlux, String environmentId, HttpHeaders httpHeaders, Boolean operateWithoutPermission) {

// Cache the multipart data so it can be reused
Mono<List<Part>> cachedPartsMono = partFlux.collectList().cache();
Comment thread
ApekshaBhosale marked this conversation as resolved.
Outdated

// Build the metadata DTO
ExecuteActionMetaDTO executeActionMetaDTO = ExecuteActionMetaDTO.builder()
.headers(httpHeaders)
.operateWithoutPermission(operateWithoutPermission)
.environmentId(environmentId)
.build();
Mono<ExecuteActionDTO> executeActionDTOMono = createExecuteActionDTO(partFlux);
return executeActionDTOMono
.flatMap(executeActionDTO -> populateAndExecuteAction(executeActionDTO, executeActionMetaDTO))
.name(ACTION_EXECUTION_SERVER_EXECUTION)
.tap(Micrometer.observation(observationRegistry));

// Derive ExecuteActionDTO from cached parts
Mono<ExecuteActionDTO> executeActionDTOMono =
cachedPartsMono.flatMap(parts -> createExecuteActionDTO(Flux.fromIterable(parts)));

// Fetch the plugin using the cached data
Mono<Plugin> pluginMono = executeActionDTOMono.flatMap(executeActionDTO -> newActionService
.findById(executeActionDTO.getActionId())
.flatMap(newAction -> pluginService.findById(newAction.getPluginId()))
Comment thread
ApekshaBhosale marked this conversation as resolved.
Outdated
.cache());
executeActionMetaDTO.setPlugin(pluginMono);
// Execute the action with both plugin name and parts
return pluginMono.flatMap(plugin -> {
String pluginName = plugin.getName();
return executeActionDTOMono
.flatMap(executeActionDTO -> populateAndExecuteAction(executeActionDTO, executeActionMetaDTO))
.tag("plugin", pluginName)
.name(ACTION_EXECUTION_SERVER_EXECUTION)
.tap(Micrometer.observation(observationRegistry));
});
}

/**
Expand All @@ -322,7 +342,8 @@ public Mono<ActionExecutionResult> executeAction(

// 3. Instantiate the implementation class based on the query type
Mono<DatasourceStorage> datasourceStorageMono = getCachedDatasourceStorage(actionDTOMono, executeActionMetaDTO);
Mono<Plugin> pluginMono = getCachedPluginForActionExecution(datasourceStorageMono);
// Mono<Plugin> pluginMono = getCachedPluginForActionExecution(datasourceStorageMono);
Mono<Plugin> pluginMono = executeActionMetaDTO.getPlugin();
Mono<PluginExecutor> pluginExecutorMono = pluginExecutorHelper.getPluginExecutor(pluginMono);

// 4. Execute the query
Expand Down