11using System.Threading;
12using System.Threading.Tasks;
35 : this(null, dataPortalUrl)
44 : this(channel, ApplicationContext.DataPortalUrlString)
53 public GrpcProxy(GrpcChannel channel,
string dataPortalUrl)
59 private GrpcChannel _channel;
60 private static GrpcChannel _defaultChannel;
71 _channel = _defaultChannel;
82 _defaultChannel = channel;
85 private GrpcService.GrpcServiceClient _grpcClient;
93 return _grpcClient ??=
new GrpcService.GrpcServiceClient(
GetChannel());
105 protected override async Task<byte[]>
CallDataPortalServer(
byte[] serialized,
string operation,
string routingToken,
bool isSync)
107 ByteString outbound = ByteString.CopyFrom(serialized);
108 var request =
new RequestMessage
111 Operation = CreateOperationTag(operation, ApplicationContext.VersionRoutingTag, routingToken)
113 ResponseMessage response;
118 return response.Body.ToByteArray();
121 internal async Task<ResponseMessage> RouteMessage(RequestMessage request)
126 private string CreateOperationTag(
string operatation,
string versionToken,
string routingToken)
128 if (!
string.IsNullOrWhiteSpace(versionToken) || !
string.IsNullOrWhiteSpace(routingToken))
129 return $
"{operatation}/{routingToken}-{versionToken}";
Implements a data portal proxy to relay data portal calls to a remote application server by using gRP...
override async Task< byte[]> CallDataPortalServer(byte[] serialized, string operation, string routingToken, bool isSync)
Create message and send to Grpc server.
GrpcProxy(GrpcChannel channel)
Creates an instance of the object, initializing it to use the supplied GrpcChannel object.
virtual GrpcChannel GetChannel()
Gets the GrpcChannel used by the gRPC client.
GrpcProxy(string dataPortalUrl)
Creates an instance of the object, initializing it to use the supplied URL.
GrpcProxy(GrpcChannel channel, string dataPortalUrl)
Creates an instance of the object, initializing it to use the supplied GrpcChannel object and URL.
static void SetChannel(GrpcChannel channel)
Sets the GrpcChannel used by gRPC clients.
virtual GrpcService.GrpcServiceClient GetGrpcClient()
Get gRPC client object used by data portal.
Implements a data portal proxy to relay data portal calls to a remote application server.
string DataPortalUrl
Gets the URL address for the data portal server used by this proxy instance.