Rpc Call Proxy
来源:互联网 发布:python正则表达式语法 编辑:程序博客网 时间:2024/05/22 06:10
When communicate with Another System , for some reason need to :
1. log the time (calling time , etc)
2.Exception handling
This is a RPC caller which handles exception in each call
/// <summary> /// Remote Procedure Call Proxy /// Add log(timeline,etc) before/after RPC /// Handle Remoting Call Exception /// </summary> /// <typeparam name="TIn"></typeparam> public class EdasRpcProxy<TIn> { public delegate void ActionRef<TIn>(ref TIn parameter); public static EdasResult SyncCallRef(ActionRef<TIn> func, ref TIn parameter) { return new EdasRpcProxy<TIn>().SynCRef(func, ref parameter); } public static EdasResult SyncCall(Action<TIn> action, TIn parameter) { return new EdasRpcProxy<TIn>().SynC(action, parameter); } private EdasResult SynCRef(ActionRef<TIn> func, ref TIn parameter) { try { func(ref parameter); return EdasResult.Create(ResultCode.Ok); } catch (Exception ex) { return EdasResult.Create(ResultCode.RemoteServerErr, string.Format(eDASConstants.Messages.RpcCallError, func.Method.Name)); } } private EdasResult SynC(Action<TIn> action, TIn parameter) { try { action(parameter); return EdasResult.Create(ResultCode.Ok); } catch (Exception ex) { return EdasResult.Create(ResultCode.RemoteServerErr, string.Format(eDASConstants.Messages.RpcCallError, action.Method.Name)); } } public void AsyncC<TOut>(Func<object, TOut> func, object parameter, Action<EdasResult<TOut>> callback) { Task<TOut>.Factory.StartNew(func, parameter).ContinueWith( (t => { var entity = t.Result; if (t.Exception != null) callback(EdasResult<TOut>.CreateResult(ResultCode.RemoteServerErr, default(TOut), string.Format(eDASConstants.Messages.RpcCallError, func.Method.Name))); else callback(EdasResult<TOut>.CreateResult(ResultCode.Ok, entity)); })); } } public class EdasRpcProxy<TIn, TOut> { public delegate TOut FuncRef<TIn, TOut>(ref TIn parameter); public static EdasResult<TOut> SyncCallRef(FuncRef<TIn, TOut> func, ref TIn parameter) { return new EdasRpcProxy<TIn, TOut>().SynCRef(func, ref parameter); } public static EdasResult<TOut> SyncCall(Func<TIn, TOut> func, TIn parameter) { return new EdasRpcProxy<TIn, TOut>().SynC(func, parameter); } private EdasResult<TOut> SynCRef(FuncRef<TIn, TOut> func, ref TIn parameter) { try { var ret = func(ref parameter); return EdasResult<TOut>.CreateResult(ResultCode.Ok, ret); } catch (Exception ex) { return EdasResult<TOut>.CreateResult(ResultCode.RemoteServerErr, default(TOut), string.Format(eDASConstants.Messages.RpcCallError, func.Method.Name)); } } private EdasResult<TOut> SynC(Func<TIn, TOut> func, TIn parameter) { try { var ret = func(parameter); return EdasResult<TOut>.CreateResult(ResultCode.Ok, ret); } catch (Exception ex) { return EdasResult<TOut>.CreateResult(ResultCode.RemoteServerErr, default(TOut), string.Format(eDASConstants.Messages.RpcCallError, func.Method.Name)); } } }
0 0
- Rpc Call Proxy
- Remote Procedure Call(RPC)
- RPC(Remote procedure call)
- Apache Curator RPC Proxy --- 序
- RPC(Remote procedure call)译文
- rpc的go 和 call
- PNP : Remote Procedure Call (RPC)
- SIP Call with Proxy Server
- codis3.2安装报错dashboard.go:369: [PANIC] call rpc create-proxy to dashboard 127.0.0.1:18080 failed的处理
- pomelo之proxy组件与rpc客户端
- pomelo之proxy组件与rpc客户端
- Platform SDK: Remote Procedure Call (RPC)
- rabbitmq 教程 四 Remote procedure call (RPC)
- 概念-RPC(Remote Procedure Call)
- 深入理解Java Proxy机制 应用在 Hadoop RPC 框架
- RPC(Remote Procedure Call 远程过程调用)
- RPC:远程过程调用协议(Remote Procedure Call protocol)
- RPC:远程过程调用协议(Remote Procedure Call protocol)
- ios7的UITableVIew按字母排序的索引怎么改成背景是透明的?
- 我不小心删除了一个文件夹没有清空回收站怎么找回
- popToViewController用法
- [下载] VMware Workstation v10.0.1官方简体中文版(附永久KEY注册密钥)
- 简单的OpengGL ES 的使用
- Rpc Call Proxy
- 浅谈Gvim文件管理器NerdTree
- 【Kettle从零开始】第十弹之Kettle运行日志介绍
- HashMap,HashTable,LinkedHashMap,TreeMap的区别和联系
- 经常性无法访问某些国内网站的问题(by quqi99)
- (intermediate) UVA 带下界的网络流 1369 - Travel
- 淡淡的心灵是一杯茶
- iOS--图片缩放
- Java中split的用法