新增:1、rpcSubscribe 重载方法;2、IType 的类型值。

This commit is contained in:
梁显优 2023-04-05 15:53:00 +08:00
parent 076e8283bf
commit 4a7db13ce3
2 changed files with 18 additions and 4 deletions

View File

@ -13,9 +13,21 @@ public interface IType {
TypeToken<Integer> INT = new TypeToken<Integer>() {
};
TypeToken<Short> SHORT = new TypeToken<Short>() {
};
TypeToken<Long> LONG = new TypeToken<Long>() {
};
TypeToken<Map<String, String>> MAP = new TypeToken<Map<String, String>>() {
};
TypeToken<List<Map<String, String>>> LMAP = new TypeToken<List<Map<String, String>>>() {
};
TypeToken<List<String>> LSTRING = new TypeToken<List<String>>() {
};
TypeToken<List<Integer>> LINT = new TypeToken<List<Integer>>() {
};
}

View File

@ -1,9 +1,6 @@
package com.zdemo.zhub;
import com.zdemo.AbstractConsumer;
import com.zdemo.Event;
import com.zdemo.IConsumer;
import com.zdemo.IProducer;
import com.zdemo.*;
import net.tccn.timer.Timers;
import org.redkale.service.Service;
import org.redkale.util.*;
@ -610,6 +607,11 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer
// -- 订阅端 --
private Set<String> rpcTopics = new HashSet();
@Comment("rpc call consumer")
public <R> void rpcSubscribe(String topic, Function<Rpc<String>, RpcResult<R>> fun) {
rpcSubscribe(topic, IType.STRING, fun);
}
@Comment("rpc call consumer")
public <T, R> void rpcSubscribe(String topic, TypeToken<T> typeToken, Function<Rpc<T>, RpcResult<R>> fun) {
Consumer<String> consumer = v -> {