io.camunda.operate.store.opensearch.client.sync.OpenSearchTaskOperations Maven / Gradle / Ivy
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
* one or more contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright ownership.
* Licensed under the Camunda License 1.0. You may not use this file
* except in compliance with the Camunda License 1.0.
*/
package io.camunda.operate.store.opensearch.client.sync;
import java.util.List;
import java.util.Map;
import org.opensearch.client.opensearch.OpenSearchClient;
import org.opensearch.client.opensearch.tasks.GetTasksResponse;
import org.opensearch.client.opensearch.tasks.Info;
import org.slf4j.Logger;
public class OpenSearchTaskOperations extends OpenSearchRetryOperation {
public OpenSearchTaskOperations(Logger logger, OpenSearchClient openSearchClient) {
super(logger, openSearchClient);
}
private static String defaultTaskErrorMessage(String id) {
return String.format("Failed to fetch task %s", id);
}
public GetTasksResponse task(String id) {
return safe(() -> super.task(id), e -> defaultTaskErrorMessage(id));
}
public Map tasksWithActions(List actions) {
return safe(
() -> super.tasksWithActions(actions),
e ->
defaultTaskErrorMessage(
String.format("Failed to fetch tasksWithActions for actions %s", actions)));
}
}