Skip to content

Commit 3c18734

Browse files
authored
Update FUNCTION LOAD changes (from release 7.0 rc3) (#2973)
* Update FUNCTION LOAD changes (Release 7.0 rc3) * update FUNCTION LIST * remove function load params * fix failure * lgtm report fix
1 parent a41c7c6 commit 3c18734

13 files changed

+101
-158
lines changed

src/main/java/redis/clients/jedis/CommandObjects.java

+8-12
Original file line numberDiff line numberDiff line change
@@ -2821,14 +2821,12 @@ public final CommandObject<List<LibraryInfo>> functionListWithCode(String librar
28212821
.add(libraryNamePattern).add(WITHCODE), BuilderFactory.LIBRARY_LIST);
28222822
}
28232823

2824-
public final CommandObject<String> functionLoad(String engineName, String libraryName, String functionCode) {
2825-
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(engineName)
2826-
.add(libraryName).add(functionCode), BuilderFactory.STRING);
2824+
public final CommandObject<String> functionLoad(String functionCode) {
2825+
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(functionCode), BuilderFactory.STRING);
28272826
}
28282827

2829-
public final CommandObject<String> functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode) {
2830-
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(engineName)
2831-
.add(libraryName).addParams(params).add(functionCode), BuilderFactory.STRING);
2828+
public final CommandObject<String> functionLoadReplace(String functionCode) {
2829+
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(REPLACE).add(functionCode), BuilderFactory.STRING);
28322830
}
28332831

28342832
public final CommandObject<FunctionStats> functionStats() {
@@ -2893,14 +2891,12 @@ public final CommandObject<List<Object>> functionListWithCode(byte[] libraryName
28932891
add(libraryNamePattern).add(WITHCODE), BuilderFactory.RAW_OBJECT_LIST);
28942892
}
28952893

2896-
public final CommandObject<String> functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode) {
2897-
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(engineName)
2898-
.add(libraryName).add(functionCode), BuilderFactory.STRING);
2894+
public final CommandObject<String> functionLoad(byte[] functionCode) {
2895+
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(functionCode), BuilderFactory.STRING);
28992896
}
29002897

2901-
public final CommandObject<String> functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode) {
2902-
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(engineName)
2903-
.add(libraryName).addParams(params).add(functionCode), BuilderFactory.STRING);
2898+
public final CommandObject<String> functionLoadReplace(byte[] functionCode) {
2899+
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(REPLACE).add(functionCode), BuilderFactory.STRING);
29042900
}
29052901

29062902
public final CommandObject<String> functionRestore(byte[] serializedValue) {

src/main/java/redis/clients/jedis/Jedis.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -8843,15 +8843,15 @@ public String functionDelete(final String libraryName) {
88438843
}
88448844

88458845
@Override
8846-
public String functionLoad(final String engineName, final String libraryName, final String functionCode) {
8846+
public String functionLoad(final String functionCode) {
88478847
checkIsInMultiOrPipeline();
8848-
return connection.executeCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
8848+
return connection.executeCommand(commandObjects.functionLoad(functionCode));
88498849
}
88508850

88518851
@Override
8852-
public String functionLoad(final String engineName, final String libraryName, final FunctionLoadParams params, final String functionCode) {
8852+
public String functionLoadReplace(final String functionCode) {
88538853
checkIsInMultiOrPipeline();
8854-
return connection.executeCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
8854+
return connection.executeCommand(commandObjects.functionLoadReplace(functionCode));
88558855
}
88568856

88578857
@Override
@@ -9447,15 +9447,15 @@ public List<Object> functionListWithCode(final byte[] libraryNamePattern) {
94479447
}
94489448

94499449
@Override
9450-
public String functionLoad(final byte[] engineName, final byte[] libraryName, final byte[] functionCode) {
9450+
public String functionLoad(final byte[] functionCode) {
94519451
checkIsInMultiOrPipeline();
9452-
return connection.executeCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
9452+
return connection.executeCommand(commandObjects.functionLoad(functionCode));
94539453
}
94549454

94559455
@Override
9456-
public String functionLoad(final byte[] engineName, final byte[] libraryName, final FunctionLoadParams params, final byte[] functionCode) {
9456+
public String functionLoadReplace(final byte[] functionCode) {
94579457
checkIsInMultiOrPipeline();
9458-
return connection.executeCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
9458+
return connection.executeCommand(commandObjects.functionLoadReplace(functionCode));
94599459
}
94609460

94619461
@Override

src/main/java/redis/clients/jedis/MultiNodePipelineBase.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -1734,23 +1734,23 @@ public Response<List<Object>> functionListWithCode(final byte[] libraryNamePatte
17341734
}
17351735

17361736
@Override
1737-
public Response<String> functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode) {
1738-
return appendCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
1737+
public Response<String> functionLoad(byte[] functionCode) {
1738+
return appendCommand(commandObjects.functionLoad(functionCode));
17391739
}
17401740

17411741
@Override
1742-
public Response<String> functionLoad(String engineName, String libraryName, String functionCode) {
1743-
return appendCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
1742+
public Response<String> functionLoad(String functionCode) {
1743+
return appendCommand(commandObjects.functionLoad(functionCode));
17441744
}
17451745

17461746
@Override
1747-
public Response<String> functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode) {
1748-
return appendCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
1747+
public Response<String> functionLoadReplace(byte[] functionCode) {
1748+
return appendCommand(commandObjects.functionLoadReplace(functionCode));
17491749
}
17501750

17511751
@Override
1752-
public Response<String> functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode) {
1753-
return appendCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
1752+
public Response<String> functionLoadReplace(String functionCode) {
1753+
return appendCommand(commandObjects.functionLoadReplace(functionCode));
17541754
}
17551755

17561756
@Override

src/main/java/redis/clients/jedis/Pipeline.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -1736,23 +1736,23 @@ public Response<List<Object>> functionListWithCode(final byte[] libraryNamePatte
17361736
}
17371737

17381738
@Override
1739-
public Response<String> functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode) {
1740-
return appendCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
1739+
public Response<String> functionLoad(byte[] functionCode) {
1740+
return appendCommand(commandObjects.functionLoad(functionCode));
17411741
}
17421742

17431743
@Override
1744-
public Response<String> functionLoad(String engineName, String libraryName, String functionCode) {
1745-
return appendCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
1744+
public Response<String> functionLoad(String functionCode) {
1745+
return appendCommand(commandObjects.functionLoad(functionCode));
17461746
}
17471747

17481748
@Override
1749-
public Response<String> functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode) {
1750-
return appendCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
1749+
public Response<String> functionLoadReplace(byte[] functionCode) {
1750+
return appendCommand(commandObjects.functionLoadReplace(functionCode));
17511751
}
17521752

17531753
@Override
1754-
public Response<String> functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode) {
1755-
return appendCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
1754+
public Response<String> functionLoadReplace(String functionCode) {
1755+
return appendCommand(commandObjects.functionLoadReplace(functionCode));
17561756
}
17571757

17581758
@Override

src/main/java/redis/clients/jedis/TransactionBase.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -1803,23 +1803,23 @@ public Response<List<Object>> functionListWithCode(final byte[] libraryNamePatte
18031803
}
18041804

18051805
@Override
1806-
public Response<String> functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode) {
1807-
return appendCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
1806+
public Response<String> functionLoad(byte[] functionCode) {
1807+
return appendCommand(commandObjects.functionLoad(functionCode));
18081808
}
18091809

18101810
@Override
1811-
public Response<String> functionLoad(String engineName, String libraryName, String functionCode) {
1812-
return appendCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
1811+
public Response<String> functionLoad(String functionCode) {
1812+
return appendCommand(commandObjects.functionLoad(functionCode));
18131813
}
18141814

18151815
@Override
1816-
public Response<String> functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode) {
1817-
return appendCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
1816+
public Response<String> functionLoadReplace(byte[] functionCode) {
1817+
return appendCommand(commandObjects.functionLoadReplace(functionCode));
18181818
}
18191819

18201820
@Override
1821-
public Response<String> functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode) {
1822-
return appendCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
1821+
public Response<String> functionLoadReplace(String functionCode) {
1822+
return appendCommand(commandObjects.functionLoadReplace(functionCode));
18231823
}
18241824

18251825
@Override

src/main/java/redis/clients/jedis/UnifiedJedis.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -3140,13 +3140,13 @@ public List<LibraryInfo> functionListWithCode(String libraryNamePattern) {
31403140
}
31413141

31423142
@Override
3143-
public String functionLoad(String engineName, String libraryName, String functionCode) {
3144-
return executeCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
3143+
public String functionLoad(String functionCode) {
3144+
return executeCommand(commandObjects.functionLoad(functionCode));
31453145
}
31463146

31473147
@Override
3148-
public String functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode) {
3149-
return executeCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
3148+
public String functionLoadReplace(String functionCode) {
3149+
return executeCommand(commandObjects.functionLoadReplace(functionCode));
31503150
}
31513151

31523152
@Override
@@ -3195,13 +3195,13 @@ public List<Object> functionListWithCode(final byte[] libraryNamePattern) {
31953195
}
31963196

31973197
@Override
3198-
public String functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode) {
3199-
return executeCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
3198+
public String functionLoad(byte[] functionCode) {
3199+
return executeCommand(commandObjects.functionLoad(functionCode));
32003200
}
32013201

32023202
@Override
3203-
public String functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode) {
3204-
return executeCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
3203+
public String functionLoadReplace(byte[] functionCode) {
3204+
return executeCommand(commandObjects.functionLoadReplace(functionCode));
32053205
}
32063206

32073207
@Override

src/main/java/redis/clients/jedis/commands/FunctionBinaryCommands.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import redis.clients.jedis.args.FlushMode;
44
import redis.clients.jedis.args.FunctionRestorePolicy;
5-
import redis.clients.jedis.params.FunctionLoadParams;
65
import redis.clients.jedis.resps.FunctionStats;
76
import redis.clients.jedis.resps.LibraryInfo;
87

@@ -89,22 +88,21 @@ public interface FunctionBinaryCommands {
8988

9089
/**
9190
* Load a library to Redis.
92-
* @param engineName the name of the execution engine for the library
93-
* @param libraryName the unique name of the library
94-
* @param functionCode the source code
95-
* @return OK
91+
* @param functionCode the source code. The library payload must start
92+
* with Shebang statement that provides a metadata
93+
* about the library (like the engine to use and the library name).
94+
* Shebang format: #!<engine name> name=<library name>.
95+
* Currently engine name must be lua.
96+
* @return The library name that was loaded
9697
*/
97-
String functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode);
98+
String functionLoad(byte[] functionCode);
9899

99100
/**
100-
* Load a library to Redis.
101-
* @param engineName the name of the execution engine for the library
102-
* @param libraryName the unique name of the library
103-
* @param params {@link FunctionLoadParams}
101+
* Load a library to Redis. Will replace the current library if it already exists.
104102
* @param functionCode the source code
105-
* @return OK
103+
* @return The library name that was loaded
106104
*/
107-
String functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode);
105+
String functionLoadReplace(byte[] functionCode);
108106

109107
/**
110108
* Restore libraries from the serialized payload. Default policy is APPEND.

src/main/java/redis/clients/jedis/commands/FunctionCommands.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import redis.clients.jedis.args.FlushMode;
44
import redis.clients.jedis.args.FunctionRestorePolicy;
5-
import redis.clients.jedis.params.FunctionLoadParams;
65
import redis.clients.jedis.resps.FunctionStats;
76
import redis.clients.jedis.resps.LibraryInfo;
87

@@ -93,22 +92,21 @@ public interface FunctionCommands {
9392

9493
/**
9594
* Load a library to Redis.
96-
* @param engineName the name of the execution engine for the library
97-
* @param libraryName the unique name of the library
98-
* @param functionCode the source code
99-
* @return OK
95+
* @param functionCode the source code. The library payload must start
96+
* with Shebang statement that provides a metadata
97+
* about the library (like the engine to use and the library name).
98+
* Shebang format: #!<engine name> name=<library name>.
99+
* Currently engine name must be lua.
100+
* @return The library name that was loaded
100101
*/
101-
String functionLoad(String engineName, String libraryName, String functionCode);
102+
String functionLoad(String functionCode);
102103

103104
/**
104-
* Load a library to Redis.
105-
* @param engineName the name of the execution engine for the library
106-
* @param libraryName the unique name of the library
107-
* @param params {@link FunctionLoadParams}
105+
* Load a library to Redis. Will replace the current library if it already exists.
108106
* @param functionCode the source code
109-
* @return OK
107+
* @return The library name that was loaded
110108
*/
111-
String functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode);
109+
String functionLoadReplace(String functionCode);
112110

113111
/**
114112
* Restore libraries from the serialized payload. Default policy is APPEND.

src/main/java/redis/clients/jedis/commands/FunctionPipelineBinaryCommands.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import redis.clients.jedis.Response;
44
import redis.clients.jedis.args.FlushMode;
55
import redis.clients.jedis.args.FunctionRestorePolicy;
6-
import redis.clients.jedis.params.FunctionLoadParams;
76

87
import java.util.List;
98

@@ -31,9 +30,9 @@ public interface FunctionPipelineBinaryCommands {
3130

3231
Response<List<Object>> functionListWithCode(byte[] libraryNamePattern);
3332

34-
Response<String> functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode);
33+
Response<String> functionLoad(byte[] functionCode);
3534

36-
Response<String> functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode);
35+
Response<String> functionLoadReplace(byte[] functionCode);
3736

3837
Response<String> functionRestore(byte[] serializedValue);
3938

src/main/java/redis/clients/jedis/commands/FunctionPipelineCommands.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import redis.clients.jedis.Response;
44
import redis.clients.jedis.args.FlushMode;
55
import redis.clients.jedis.args.FunctionRestorePolicy;
6-
import redis.clients.jedis.params.FunctionLoadParams;
76
import redis.clients.jedis.resps.FunctionStats;
87
import redis.clients.jedis.resps.LibraryInfo;
98

@@ -33,9 +32,9 @@ public interface FunctionPipelineCommands {
3332

3433
Response<List<LibraryInfo>> functionListWithCode(String libraryNamePattern);
3534

36-
Response<String> functionLoad(String engineName, String libraryName, String functionCode);
35+
Response<String> functionLoad(String functionCode);
3736

38-
Response<String> functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode);
37+
Response<String> functionLoadReplace(String functionCode);
3938

4039
Response<String> functionRestore(byte[] serializedValue);
4140

src/main/java/redis/clients/jedis/params/FunctionLoadParams.java

-41
This file was deleted.

0 commit comments

Comments
 (0)