Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Triggers and Functions feature #3968

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions src/main/java/redis/clients/jedis/CommandObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -4414,26 +4414,31 @@ public final CommandObject<Map<String, Object>> graphConfigGet(String configName
// RedisGraph commands

// RedisGears commands
@Deprecated
public final CommandObject<String> tFunctionLoad(String libraryCode, TFunctionLoadParams params) {
return new CommandObject<>(commandArguments(GearsCommand.TFUNCTION).add(GearsKeyword.LOAD)
.addParams(params).add(libraryCode), BuilderFactory.STRING);
}

@Deprecated
public final CommandObject<String> tFunctionDelete(String libraryName) {
return new CommandObject<>(commandArguments(GearsCommand.TFUNCTION).add(GearsKeyword.DELETE)
.add(libraryName), BuilderFactory.STRING);
}

@Deprecated
public final CommandObject<List<GearsLibraryInfo>> tFunctionList(TFunctionListParams params) {
return new CommandObject<>(commandArguments(GearsCommand.TFUNCTION).add(GearsKeyword.LIST)
.addParams(params), GearsLibraryInfo.GEARS_LIBRARY_INFO_LIST);
}

@Deprecated
public final CommandObject<Object> tFunctionCall(String library, String function, List<String> keys, List<String> args) {
return new CommandObject<>(commandArguments(GearsCommand.TFCALL).add(library + "." + function)
.add(keys.size()).keys(keys).addObjects(args), BuilderFactory.AGGRESSIVE_ENCODED_OBJECT);
}

@Deprecated
public final CommandObject<Object> tFunctionCallAsync(String library, String function, List<String> keys, List<String> args) {
return new CommandObject<>(commandArguments(GearsCommand.TFCALLASYNC).add(library + "." + function)
.add(keys.size()).keys(keys).addObjects(args), BuilderFactory.AGGRESSIVE_ENCODED_OBJECT);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/redis/clients/jedis/UnifiedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -4984,26 +4984,31 @@ public Map<String, Object> graphConfigGet(String configName) {
// RedisGraph commands

// RedisGears commands
@Deprecated
@Override
public String tFunctionLoad(String libraryCode, TFunctionLoadParams params) {
return executeCommand(commandObjects.tFunctionLoad(libraryCode, params));
}

@Deprecated
@Override
public String tFunctionDelete(String libraryName) {
return executeCommand(commandObjects.tFunctionDelete(libraryName));
}

@Deprecated
@Override
public List<GearsLibraryInfo> tFunctionList(TFunctionListParams params) {
return executeCommand(commandObjects.tFunctionList(params));
}

@Deprecated
@Override
public Object tFunctionCall(String library, String function, List<String> keys, List<String> args) {
return executeCommand(commandObjects.tFunctionCall(library, function, keys, args));
}

@Deprecated
@Override
public Object tFunctionCallAsync(String library, String function, List<String> keys, List<String> args) {
return executeCommand(commandObjects.tFunctionCallAsync(library, function, keys, args));
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/redis/clients/jedis/gears/RedisGearsCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@

import java.util.List;

@Deprecated
public interface RedisGearsCommands {

default String tFunctionLoad(String libraryCode) {
@Deprecated default String tFunctionLoad(String libraryCode) {
return tFunctionLoad(libraryCode, TFunctionLoadParams.loadParams());
}

String tFunctionLoad(String libraryCode, TFunctionLoadParams params);
@Deprecated String tFunctionLoad(String libraryCode, TFunctionLoadParams params);

default List<GearsLibraryInfo> tFunctionList() {
@Deprecated default List<GearsLibraryInfo> tFunctionList() {
return tFunctionList(TFunctionListParams.listParams());
}

List<GearsLibraryInfo> tFunctionList(TFunctionListParams params);
@Deprecated List<GearsLibraryInfo> tFunctionList(TFunctionListParams params);

String tFunctionDelete(String libraryName);
@Deprecated String tFunctionDelete(String libraryName);

Object tFunctionCall(String library, String function, List<String> keys, List<String> args);
@Deprecated Object tFunctionCall(String library, String function, List<String> keys, List<String> args);

Object tFunctionCallAsync(String library, String function, List<String> keys, List<String> args);
@Deprecated Object tFunctionCallAsync(String library, String function, List<String> keys, List<String> args);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import redis.clients.jedis.commands.ProtocolCommand;
import redis.clients.jedis.util.SafeEncoder;

@Deprecated
public class RedisGearsProtocol {

@Deprecated
public enum GearsCommand implements ProtocolCommand {

TFUNCTION,
TFCALL,
TFCALLASYNC;
@Deprecated TFUNCTION,
@Deprecated TFCALL,
@Deprecated TFCALLASYNC;

private final byte[] raw;

Expand All @@ -24,6 +26,7 @@ public byte[] getRaw() {
}
}

@Deprecated
public enum GearsKeyword implements Rawable {

CONFIG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.util.Collections;

@Deprecated
public class TFunctionListParams implements IParams {
private boolean withCode = false;
private int verbose;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import redis.clients.jedis.gears.RedisGearsProtocol.GearsKeyword;
import redis.clients.jedis.params.IParams;

@Deprecated
public class TFunctionLoadParams implements IParams {
private boolean replace = false;
private String config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import static redis.clients.jedis.BuilderFactory.*;

@Deprecated
public class FunctionInfo {
private final String name;
private final String description;
Expand Down Expand Up @@ -40,6 +41,7 @@ public FunctionInfo(String name, String description, boolean isAsync, List<Strin
this.flags = flags;
}

@Deprecated
public static final Builder<List<FunctionInfo>> FUNCTION_INFO_LIST = new Builder<List<FunctionInfo>>() {
@Override
public List<FunctionInfo> build(Object data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;
import java.util.stream.Collectors;

@Deprecated
public class FunctionStreamInfo {
private final String name;
private final String idToReadFrom;
Expand Down Expand Up @@ -67,6 +68,7 @@ public FunctionStreamInfo(String name, String idToReadFrom, String lastError,
this.pendingIds = pendingIds;
}

@Deprecated
public static final Builder<List<FunctionStreamInfo>> STREAM_INFO_LIST = new Builder<List<FunctionStreamInfo>>() {
@Override
public List<FunctionStreamInfo> build(Object data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import static redis.clients.jedis.gears.resps.StreamTriggerInfo.STREAM_TRIGGER_INFO_LIST;
import static redis.clients.jedis.gears.resps.TriggerInfo.KEYSPACE_TRIGGER_INFO_LIST;

@Deprecated
public class GearsLibraryInfo {
private final String apiVersion;
private final List<String> clusterFunctions;
Expand Down Expand Up @@ -90,6 +91,7 @@ public String getUser() {
return user;
}

@Deprecated
public static final Builder<GearsLibraryInfo> GEARS_LIBRARY_INFO = new Builder<GearsLibraryInfo>() {
@Override
public GearsLibraryInfo build(Object data) {
Expand Down Expand Up @@ -171,6 +173,7 @@ public GearsLibraryInfo build(Object data) {
}
};

@Deprecated
public static final Builder<List<GearsLibraryInfo>> GEARS_LIBRARY_INFO_LIST = new Builder<List<GearsLibraryInfo>>() {
@Override
public List<GearsLibraryInfo> build(Object data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static redis.clients.jedis.BuilderFactory.*;
import static redis.clients.jedis.gears.resps.FunctionStreamInfo.STREAM_INFO_LIST;

@Deprecated
public class StreamTriggerInfo {
private final String name;
private final String description;
Expand Down Expand Up @@ -60,6 +61,7 @@ public StreamTriggerInfo(String name, String description, String prefix,
this(name, description, prefix, window, trim, Collections.emptyList());
}

@Deprecated
public static final Builder<List<StreamTriggerInfo>> STREAM_TRIGGER_INFO_LIST = new Builder<List<StreamTriggerInfo>>() {
@Override
public List<StreamTriggerInfo> build(Object data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static redis.clients.jedis.BuilderFactory.LONG;
import static redis.clients.jedis.BuilderFactory.STRING;

@Deprecated
public class TriggerInfo {
private final String name;
private final String description;
Expand Down Expand Up @@ -80,6 +81,7 @@ public TriggerInfo(String name, String description, String lastError, long numFi
this.totalExecutionTime = totalExecutionTime;
}

@Deprecated
public static final Builder<List<TriggerInfo>> KEYSPACE_TRIGGER_INFO_LIST = new Builder<List<TriggerInfo>>() {
@Override
public List<TriggerInfo> build(Object data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.ArrayList;
import java.util.List;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;

import redis.clients.jedis.RedisProtocol;
Expand All @@ -19,6 +20,7 @@
/**
* Tests related to <a href="https://redis.io/commands/?group=triggers_and_functions">Triggers and functions</a> commands.
*/
@Ignore
public class CommandObjectsTriggersAndFunctionsCommandsTest extends CommandObjectsModulesTestBase {

public CommandObjectsTriggersAndFunctionsCommandsTest(RedisProtocol protocol) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.junit.Ignore;
import org.junit.Test;
import redis.clients.jedis.gears.TFunctionListParams;
import redis.clients.jedis.gears.TFunctionLoadParams;
import redis.clients.jedis.gears.resps.GearsLibraryInfo;

@Ignore
public class UnifiedJedisTriggersAndFunctionsCommandsTest extends UnifiedJedisMockedTestBase {

@Test
Expand Down
20 changes: 11 additions & 9 deletions src/test/java/redis/clients/jedis/modules/gears/GearsTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package redis.clients.jedis.modules.gears;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand All @@ -15,22 +25,14 @@
import redis.clients.jedis.modules.RedisModuleCommandsTestBase;
import redis.clients.jedis.gears.resps.GearsLibraryInfo;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

@Ignore
@RunWith(Parameterized.class)
public class GearsTest extends RedisModuleCommandsTestBase {

Expand Down
Loading