com.gitee.jmash.file.client.cdi.FileClientConfig Maven / Gradle / Ivy
package com.gitee.jmash.file.client.cdi;
import com.gitee.jmash.common.grpc.client.GrpcChannel;
import io.grpc.ManagedChannel;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Singleton;
import jmash.basic.FileBasicGrpc;
import jmash.file.FileGrpc;
/** File Client Config . */
@ApplicationScoped
public class FileClientConfig {
protected static ManagedChannel channel = null;
public static ManagedChannel getManagedChannel() {
if (null != channel && !channel.isShutdown() && !channel.isTerminated()) {
return channel;
}
// k8s环境获取后端服务,本地环境获取测试服务.
channel = GrpcChannel.getServiceChannel("jmash-file-service");
return channel;
}
/** FileBlockingStub. */
@Produces
@Singleton
public static FileGrpc.FileBlockingStub getFileBlockingStub() {
return FileGrpc.newBlockingStub(getManagedChannel());
}
/** FileFutureStub. */
@Produces
@Singleton
public static FileGrpc.FileFutureStub getFileFutureStub() {
return FileGrpc.newFutureStub(getManagedChannel());
}
/** FileStub. */
@Produces
@Singleton
public static FileGrpc.FileStub getFileStub() {
return FileGrpc.newStub(getManagedChannel());
}
/** FileBasicBlockingStub. */
@Produces
@Singleton
public static FileBasicGrpc.FileBasicBlockingStub getFileBasicBlockingStub() {
return FileBasicGrpc.newBlockingStub(getManagedChannel());
}
/** FileBasicFutureStub. */
@Produces
@Singleton
public static FileBasicGrpc.FileBasicFutureStub getFileBasicFutureStub() {
return FileBasicGrpc.newFutureStub(getManagedChannel());
}
/** FileBasicStub. */
@Produces
@Singleton
public static FileBasicGrpc.FileBasicStub getFileBasicStub() {
return FileBasicGrpc.newStub(getManagedChannel());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy