appsettings.json 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  1. {
  2. "Sers": {
  3. /* 通讯层配置 */
  4. "CL": {
  5. /* 共用配置,子项共用,覆写子项未指定的配置 */
  6. "Config": {
  7. "workThread": {
  8. // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
  9. "mode": "LongThread",
  10. /* 后台处理消息的线程个数(单位个,默认2) */
  11. "threadCount": 2,
  12. /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
  13. "maxThreadCount": 100,
  14. /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
  15. "pendingQueueLength": 100000,
  16. /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
  17. "timeoutMs": 300000
  18. },
  19. /* 请求超时时间(单位ms,默认300000) */
  20. "requestTimeoutMs": 300000,
  21. //HeartBeat
  22. /* 心跳检测时间间隔(单位ms,默认10000,若指定为0则不进行心跳检测) */
  23. "heartBeatIntervalMs": 10000,
  24. /* 心跳检测超时时间(单位ms,默认30000) */
  25. "heartBeatTimeoutMs": 30000,
  26. /* 心跳检测失败重试次数(单位次,默认10) */
  27. "heartBeatRetryCount": 10,
  28. /* 数据传输 加密协议,可多个,可不指定 */
  29. "//security": [
  30. {
  31. // SampleSecurity
  32. /* 在此Assembly中查找security */
  33. "assemblyFile": "Sers.Core.dll",
  34. /* the class of security in assemblyFile. 必须继承接口 Sers.Core.Util.StreamSecurity.ISecurity */
  35. "className": "Sers.Core.Util.StreamSecurity.Security.SampleSecurity",
  36. /* (x.2) config */
  37. /* 加密密钥 */
  38. "secret": "security"
  39. },
  40. {
  41. // SampleSecurity
  42. /* 若不指定assemblyFile和className 则默认为Sers.Core.Util.StreamSecurity.Security.SampleSecurity */
  43. "secret": "Two layer encryption"
  44. }
  45. ],
  46. /* 连接秘钥,用以验证连接安全性。服务端和客户端必须一致 */
  47. "secretKey": "SersCL"
  48. },
  49. /* one conn is one channel.can be multiable */
  50. "Server": [
  51. {
  52. //Ipc.NamedPipe
  53. /* (x.1) type */
  54. /* 在此Assembly中查找builder */
  55. "assemblyFile": "Sers.CL.Ipc.NamedPipe.dll",
  56. /* the class of builder in assemblyFile */
  57. //"className": "Sers.CL.Ipc.NamedPipe.OrganizeServerBuilder",
  58. /* (x.2) config */
  59. /* 命名管道名称。例如: "Sers.CL.Ipc" */
  60. "pipeName": "Sers.CL.Ipc.4501"
  61. },
  62. {
  63. // Socket.Iocp
  64. /* (x.1) type - Iocp */
  65. /* the class of builder in assemblyFile */
  66. "className": "Sers.CL.Socket.Iocp.OrganizeServerBuilder",
  67. /* 通信模式(默认值:Simple)。可为 Simple、Timer、ThreadWait */
  68. //"mode": "ThreadWait",
  69. /* 接收缓存区大小(单位:byte,默认:8192) */
  70. //"receiveBufferSize": 8192,
  71. /* 发送缓冲区刷新间隔(单位:毫秒,默认:1)(仅当mode为Timer和ThreadWait时有效) */
  72. //"sendFlushInterval": 1,
  73. /* 发送缓冲区数据块的最小大小(单位:byte,默认 1000000)(仅当mode为Timer和ThreadWait时有效) */
  74. //"sendBufferSize": 1000000,
  75. /* 发送缓冲区个数(默认1024)(仅当mode为Timer和ThreadWait时有效) */
  76. //"sendBufferCount": 1024,
  77. /* (x.2) config */
  78. /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.cloud"。*/
  79. //"host": "127.0.0.1",
  80. /* 服务端 监听端口号。例如: 4501 */
  81. "port": 4501
  82. },
  83. {
  84. // Socket.ThreadWait
  85. /* (x.1) type - Socket */
  86. /* the class of builder in assemblyFile */
  87. //"className": "Sers.CL.Socket.ThreadWait.OrganizeServerBuilder",
  88. /* (x.2) config */
  89. /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.cloud"。*/
  90. //"host": "127.0.0.1",
  91. /* 服务端 监听端口号。例如: 4501 */
  92. "port": 4501
  93. },
  94. {
  95. // Zmq.ThreadWait
  96. /* (x.1) type */
  97. /* 在此Assembly中查找builder */
  98. "assemblyFile": "Sers.CL.ClrZmq.ThreadWait.dll",
  99. /* the class of builder in assemblyFile */
  100. //"className": "Sers.CL.ClrZmq.ThreadWait.OrganizeServerBuilder",
  101. /* (x.2) config */
  102. /* 地址。例如: "tcp://*:4502" 、 "ipc://4502" */
  103. "endpoint": "tcp://*:4502"
  104. },
  105. {
  106. // WebSocket
  107. /* (x.1) type */
  108. /* 在此Assembly中查找builder */
  109. "assemblyFile": "Sers.CL.WebSocket.dll",
  110. /* the class of builder in assemblyFile */
  111. //"className": "Sers.CL.WebSocket.OrganizeServerBuilder",
  112. /* (x.2) config */
  113. /* 服务端地址(默认为 "ws://0.0.0.0:4503") */
  114. "host": "ws://0.0.0.0:4503",
  115. /* SSL证书(若使用wss则必须指定证书) */
  116. "//certificate": {
  117. "filePath": "Data/ssl.pfx",
  118. "password": ""
  119. }
  120. },
  121. {
  122. // Zmq.FullDuplex
  123. /* (x.1) type */
  124. /* 在此Assembly中查找builder */
  125. "assemblyFile": "Sers.CL.Zmq.FullDuplex.dll",
  126. /* the class of builder in assemblyFile */
  127. //"className": "Sers.CL.Zmq.FullDuplex.OrganizeServerBuilder",
  128. /* (x.2) config */
  129. /* 地址。例如: "tcp://*:4504" 、 "ipc://4504" */
  130. "endpoint": "tcp://*:4504"
  131. },
  132. {
  133. //Ipc.SharedMemory
  134. /* (x.1) type - Ipc.SharedMemory */
  135. /* 在此Assembly中查找builder */
  136. "assemblyFile": "Sers.CL.Ipc.SharedMemory.dll",
  137. /* the class of builder in assemblyFile */
  138. //"className": "Sers.CL.Ipc.SharedMemory.OrganizeServerBuilder",
  139. /* (x.2) config */
  140. /* 共享内存名称。例如: "ipcTest" */
  141. "name": "ipcForStationDemo",
  142. /* 共享内存节点个数。例如: 64 */
  143. "nodeCount": 128,
  144. /* 共享内存节点大小。例如: 2048 */
  145. "nodeBufferSize": 102400
  146. },
  147. {
  148. /* (x.1) type - Ipc.SharedMemory */
  149. /* 在此Assembly中查找builder */
  150. "assemblyFile": "Sers.CL.Ipc.SharedMemory.dll",
  151. /* the class of builder in assemblyFile */
  152. //"className": "Sers.CL.Ipc.SharedMemory.OrganizeServerBuilder",
  153. /* (x.2) config */
  154. /* 共享内存名称。例如: "ipcTest" */
  155. "name": "ipcForRobot",
  156. /* 共享内存节点个数。例如: 64 */
  157. "nodeCount": 128,
  158. /* 共享内存节点大小。例如: 2048 */
  159. "nodeBufferSize": 102400
  160. }
  161. ]
  162. },
  163. // RpcData序列化模式。可不指定。默认为Text。
  164. // 可为 Newtonsoft、Text、BytePointor。
  165. // 效率依次递增。BytePointor 序列化为二进制数据而不是json字符串。
  166. "RpcDataSerializeMode": "Text",
  167. /* LocalApiService 配置,可不指定 */
  168. "LocalApiService": {
  169. "workThread": {
  170. // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
  171. "mode": "LongThread",
  172. /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
  173. "threadCount": 4,
  174. /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
  175. "maxThreadCount": 100,
  176. /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
  177. "pendingQueueLength": 100000,
  178. /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
  179. "timeoutMs": 300000
  180. },
  181. /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */
  182. "//staticFiles": [
  183. {
  184. /* api路由前缀,例如 "/demo/ui/*" */
  185. "route": "/demo/ui/*",
  186. /* api描述,静态文件描述 */
  187. "apiName": "demo站点静态文件",
  188. /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录。demo:"wwwroot/demo" */
  189. "rootPath": "wwwroot/demo",
  190. /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
  191. "contentTypeMapFile": "contentTypeMap.json",
  192. /* 回应静态文件时额外添加的http回应头。可不指定。 */
  193. "responseHeaders": {
  194. //设置浏览器静态文件缓存3600秒
  195. "Cache-Control": "public,max-age=3600"
  196. }
  197. }
  198. ],
  199. /* 默认站点名称,可多个,可不指定 */
  200. //"apiStationNames": [ "demo" ],
  201. /* Api加载器配置 */
  202. "//ApiLoaders": [
  203. {
  204. /* 在此Assembly中查找api加载器(如 Sers.Core.dll 、Sers.NetcoreLoader.dll 、 Sers.Serslot.dll ) */
  205. //"loader_assemblyFile": "Sers.Core.dll",
  206. /* 加载器的类名,可为 Sers.SersLoader.ApiLoader 、 Sers.NetcoreLoader.ApiLoader、 Sers.Serslot.ApiLoader 等。若不指定则默认为"Sers.SersLoader.ApiLoader" */
  207. //"loader_className": "Sers.SersLoader.ApiLoader",
  208. //(通过反射从此包中获取要加载的api)
  209. /* 在此Assembly中查找服务(如 Did.SersLoader.Demo.dll)(assembly、assemblyFile、assemblyName 指定任一即可) */
  210. "assemblyFile": "Did.SersLoader.Demo.dll",
  211. /* 在此Assembly中查找服务(如 Did.SersLoader.Demo)(assembly、assemblyFile、assemblyName 指定任一即可) */
  212. //"assemblyName": "Did.SersLoader.Demo",
  213. /* 强制指定ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  214. //"apiStationName_Force": "",
  215. /* ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  216. "apiStationName": "demo"
  217. /* 强制路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低: routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix) */
  218. //"routePrefix_Force": "",
  219. /* 路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低: routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix ) */
  220. //"routePrefix": ""
  221. }
  222. ],
  223. /* 调用Api时的自定义Scope对象。可不指定。事件顺序为 OnCreateScope -> BeforeCallApi -> OnDispose */
  224. "//OnCreateScope": [
  225. {
  226. //ApiTrace publisher(推送ApiTrace数据到ApiTrace.Collector)
  227. /* 在此Assembly中加载类 */
  228. "assemblyFile": "Sers.Core.dll",
  229. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.ApiScope.IApiScopeEvent */
  230. "className": "Sers.Core.Module.Api.LocalApi.ApiTrace.ApiTracePublisher",
  231. /* 搜集器名称(根据此名称推送到对应的搜集器,搜集器在ApiTrace.Collector中配置),若不指定则不加载 */
  232. "collectorName": "default"
  233. }
  234. ],
  235. /* 调用api前的事件,可不指定。事件顺序为 OnCreateScope -> BeforeCallApi -> OnDispose */
  236. "//BeforeCallApi": [
  237. {
  238. /* 在此Assembly中加载类 */
  239. "assemblyFile": "Sers.Core.dll",
  240. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  241. "className": "Bearer",
  242. //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  243. /* 验证at接口的地址 */
  244. "api_verifyAt": "/AuthCenter/account/verifyAt",
  245. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  246. "api_httpMethod": "POST"
  247. },
  248. {
  249. /* 在此Assembly中加载类 */
  250. "assemblyFile": "Sers.Core.Module.Api.ApiEvent.BeforeCallApi.JsonWebToken.dll",
  251. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  252. //"className": "Sers.Core.Module.Api.ApiEvent.BeforeCallApi.JsonWebToken.JsonWebToken",
  253. //在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),或cookie中的Authorization, 并把jwt中的Claims信息放到 rpcData.user.userInfo
  254. // if token is valid, will set rpcData.caller.source to CallerSource
  255. "CallerSource": "Internal",
  256. //"issuer": "https://sso.lith.cloud:4",
  257. //"audiences": [ "http://localhost:4580" ],
  258. "publicKeysDiscovery_Url": "https://sso.lith.cloud:4/oauth2/v1/discovery/keys"
  259. },
  260. {
  261. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  262. "className": "AccountInCookie",
  263. "account": [
  264. {
  265. "userToken": "admin_123456",
  266. //"CallerSource": "Internal",
  267. "userInfo": {
  268. "name": "超级管理员",
  269. "入口": "Gover网关"
  270. }
  271. }
  272. ]
  273. }
  274. ]
  275. },
  276. /* ServiceStation配置,可不指定 */
  277. "ServiceStation": {
  278. /* 自动上报cpu Usage。不指定则不上报 */
  279. "//UsageReporter": {
  280. /* 上报时间间隔(单位:秒) */
  281. "intervalSecond": 2
  282. },
  283. /* serviceStation站点信息 */
  284. "serviceStationInfo": {
  285. /* 服务站点名称 */
  286. "serviceStationName": "ServiceCenter",
  287. /* 服务站点版本信息,若不指定则为入口链接库的版本号 */
  288. //"stationVersion": "2.1.1",
  289. /* [json]服务站点额外信息,可不指定 */
  290. "info": null
  291. }
  292. },
  293. /* ServiceCenter 配置,可不指定 */
  294. "ServiceCenter": {
  295. /* 是否 输出Api注册事件到(Info)Log文件。默认:true */
  296. "ApiRegistEvent_Print": true,
  297. /* api路由管理方式,可不指定。可为:"RESTful","IgnoreHttpMethod"。若不指定或未指定有效值,则默认为"RESTful" */
  298. //"ApiRouteType": "IgnoreHttpMethod",
  299. //调用api前的事件,可不指定
  300. "//BeforeCallApi": [
  301. {
  302. /* 在此Assembly中加载类 */
  303. "assemblyFile": "Sers.Core.dll",
  304. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  305. "className": "Bearer",
  306. //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  307. /* 验证at接口的地址 */
  308. "api_verifyAt": "/AuthCenter/account/verifyAt",
  309. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  310. "api_httpMethod": "POST"
  311. },
  312. {
  313. /* 在此Assembly中加载类 */
  314. "assemblyFile": "Sers.Core.Module.Api.ApiEvent.BeforeCallApi.JsonWebToken.dll",
  315. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  316. //"className": "Sers.Core.Module.Api.ApiEvent.BeforeCallApi.JsonWebToken.JsonWebToken",
  317. //在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),或cookie中的Authorization, 并把jwt中的Claims信息放到 rpcData.user.userInfo
  318. // if token is valid, will set rpcData.caller.source to CallerSource
  319. "CallerSource": "Internal",
  320. //"issuer": "https://sso.lith.cloud:4",
  321. //"audiences": [ "http://localhost:4580" ],
  322. "publicKeysDiscovery_Url": "https://sso.lith.cloud:4/oauth2/v1/discovery/keys"
  323. },
  324. {
  325. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  326. //"className": "AccountInCookie",
  327. "account": [
  328. {
  329. "userToken": "admin_123456",
  330. //"CallerSource": "Internal",
  331. "userInfo": {
  332. "name": "超级管理员",
  333. "入口": "Gover网关"
  334. }
  335. }
  336. ]
  337. }
  338. ]
  339. },
  340. /* 动态加载的App事件 */
  341. "AppEvent": [
  342. {
  343. //ApiTrace publisher(推送ApiTrace数据到ApiTrace.Collector)
  344. /* 在此Assembly中加载类 */
  345. "assemblyFile": "Sers.Gover.dll",
  346. /* 动态加载的类名,必须继承接口 Sers.Core.Module.App.AppEvent.IAppEvent */
  347. //"className": "Sers.Gover.Base.AppEvent.ApiTracePublisher",
  348. /* 搜集器名称(根据此名称推送到对应的搜集器,搜集器在ApiTrace.Collector中配置),若不指定则不加载 */
  349. "collectorName": "default"
  350. }
  351. ],
  352. /* ApiTrace 搜集器配置,可不指定 */
  353. "ApiTrace": {
  354. "Collector": [
  355. { //搜集ApiTrace到 Log/{yyyy-MM}/[{yyyy-MM-dd}]ApiTrace.txt文件
  356. /* 搜集器名称(ApiTrace推送端根据此名称推送到对应的搜集器),若不指定则不加载 */
  357. "collectorName": "default",
  358. /* 在此Assembly中加载类 */
  359. "assemblyFile": "Sers.Core.dll",
  360. /* 动态加载的类名,必须继承接口 Sers.Core.Module.ApiTrace.Collector.IApiTraceCollector */
  361. //"className": "Sers.Core.Module.ApiTrace.Collector.TxtCollector", //亦可为TxtCollector
  362. "tags": {
  363. // 可为 requestRpc requestData responseRpc responseData
  364. "route": "{{requestRpc.route}}",
  365. //"{{requestRpc.route}}": "route",
  366. "url": "{{requestRpc.http.url}}",
  367. "method": "{{requestRpc.http.method}}",
  368. "requestRpc": "{{requestRpc}}",
  369. "requestData": "{{requestData}}",
  370. "responseRpc": "{{responseRpc}}",
  371. "responseState": "{{responseRpc.http.headers.responseState}}",
  372. //"responseError_Base64": "{{responseRpc.http.headers.responseError_Base64}}"
  373. "responseData": "{{responseData}}",
  374. "responseData.error": "{{responseData.error}}"
  375. }
  376. },
  377. { //搜集ApiTrace到 splunk
  378. /* 搜集器名称(ApiTrace推送端根据此名称推送到对应的搜集器),若不指定则不加载 */
  379. "collectorName": "default",
  380. /* 在此Assembly中加载类 */
  381. "assemblyFile": "Sers.Core.dll",
  382. /* 动态加载的类名,必须继承接口 Sers.Core.Module.ApiTrace.Collector.IApiTraceCollector */
  383. //"className": "Sers.Core.Module.ApiTrace.Collector.SplunkCollector",
  384. "server": {
  385. "url": "http://192.168.20.20:8088/services/collector",
  386. "authToken": "xxxxx",
  387. "index": "dev",
  388. //若指定则在指定时间间隔统一推送数据,若不指定则立即推送。单位:ms
  389. "//intervalMs": 2000
  390. },
  391. "//hostInfo": {
  392. "host": "192.168.20.20:8088",
  393. "source": "http:sers",
  394. "sourcetype": "sers-ApiTrace"
  395. },
  396. //custome object
  397. "//appInfo": {
  398. "namespace": "sers.cloud",
  399. "appName": "mc",
  400. "moduleName": "ServiceCenter"
  401. //,"...": {}
  402. },
  403. "tags": {
  404. // 可为 requestRpc requestData responseRpc responseData
  405. "route": "{{requestRpc.route}}",
  406. //"{{requestRpc.route}}": "route",
  407. "url": "{{requestRpc.http.url}}",
  408. "method": "{{requestRpc.http.method}}",
  409. "requestRpc": "{{requestRpc}}",
  410. "requestData": "{{requestData}}",
  411. "responseRpc": "{{responseRpc}}",
  412. "responseState": "{{responseRpc.http.headers.responseState}}",
  413. //"responseError_Base64": "{{responseRpc.http.headers.responseError_Base64}}"
  414. "responseData": "{{responseData}}",
  415. "responseData.error": "{{responseData.error}}"
  416. }
  417. },
  418. { //搜集ApiTrace到 ElasticSearch
  419. /* 搜集器名称(ApiTrace推送端根据此名称推送到对应的搜集器),若不指定则不加载 */
  420. "collectorName": "default",
  421. /* 在此Assembly中加载类 */
  422. "assemblyFile": "Sers.Core.dll",
  423. /* 动态加载的类名,必须继承接口 Sers.Core.Module.ApiTrace.Collector.IApiTraceCollector */
  424. //"className": "Sers.Core.Module.ApiTrace.Collector.ElasticSearchCollector",
  425. "server": {
  426. // es address, example:"http://192.168.20.20:9200"
  427. "url": "http://192.168.20.20:9200",
  428. //es index, example:"dev"
  429. "index": "dev_apitrace",
  430. //es type, example:"_doc"
  431. //"type": "_doc",
  432. //若指定则在指定时间间隔统一推送数据,若不指定则立即推送。单位:ms
  433. "//intervalMs": 2000
  434. },
  435. //custome object
  436. "//appInfo": {
  437. "namespace": "sers.cloud",
  438. "appName": "mc",
  439. "moduleName": "ServiceCenter"
  440. //,"...": {}
  441. },
  442. "//tags": {
  443. // 可为 requestRpc requestData responseRpc responseData
  444. "route": "{{requestRpc.route}}",
  445. //"{{requestRpc.route}}": "route",
  446. "url": "{{requestRpc.http.url}}",
  447. "method": "{{requestRpc.http.method}}",
  448. "requestRpc": "{{requestRpc}}",
  449. "requestData": "{{requestData}}",
  450. "responseRpc": "{{responseRpc}}",
  451. "responseState": "{{responseRpc.http.headers.responseState}}",
  452. //"responseError_Base64": "{{responseRpc.http.headers.responseError_Base64}}"
  453. "responseData": "{{responseData}}",
  454. "responseData.error": "{{responseData.error}}"
  455. }
  456. },
  457. { //搜集ApiTrace到Zipkin链路追踪
  458. /* 搜集器名称(ApiTrace推送端根据此名称推送到对应的搜集器),若不指定则不加载 */
  459. "collectorName": "Zipkin",
  460. /* 在此Assembly中加载类 */
  461. "assemblyFile": "Sers.ApiTrace.Collector.Zipkin.dll",
  462. /* 动态加载的类名,必须继承接口 Sers.Core.Module.ApiTrace.Collector.IApiTraceCollector */
  463. //"className": "Sers.ApiTrace.Collector.Zipkin.ZipKinCollector",
  464. /* 配置 */
  465. "SamplingRate": "1.0",
  466. "zipkinCollectorUrl": "http://sers.cloud:9411",
  467. /* 若不指定则默认为ServiceCenter */
  468. "rpcName": "ServiceCenter",
  469. "tags": {
  470. // 可为 requestRpc requestData responseRpc responseData
  471. "traceName": "demoTrace",
  472. "route": "{{requestRpc.route}}",
  473. "{{requestRpc.route}}": "route",
  474. "url": "{{requestRpc.http.url}}",
  475. "method": "{{requestRpc.http.method}}",
  476. "requestRpc": "{{requestRpc}}",
  477. //"requestData": "{{requestData}}",
  478. "responseRpc": "{{responseRpc}}",
  479. "responseState": "{{responseRpc.http.headers.responseState}}",
  480. "responseError_Base64": "{{responseRpc.http.headers.responseError_Base64}}"
  481. //"responseData": "{{responseData}}",
  482. //"responseData.error": "{{responseData.error}}"
  483. }
  484. }
  485. ]
  486. },
  487. /* 网关配置。若不指定,则不开启网关服务 */
  488. "Gateway": {
  489. /* Rpc配置,可不指定 */
  490. "Rpc": {
  491. /* 网关转发的请求中的rpc 信息中的 CallerSource。(暗指调用来源,默认"OutSide") */
  492. //"CallerSource": "OutSide"
  493. },
  494. "WebHost": {
  495. /* url,可多个 */
  496. "urls": [ "http://*:4580" ],
  497. /* ssl证书,可不指定。若urls中指定了https协议,请在此指定对应的https证书 */
  498. "//certificates": [
  499. {
  500. "filePath": "Data/ssl.pfx",
  501. "password": "password"
  502. }
  503. ],
  504. /* 重定向所有的http请求到https。若不指定则不重定向 */
  505. "//httpsRedirection": {
  506. /* 重定向的地址。若不指定,则使用发起请求的host */
  507. "host": "serset.com",
  508. /* 重定向的端口号。若不指定,则使用发起请求的port */
  509. "port": 443,
  510. /* The status code used for the redirect response. The default is 307. */
  511. "statusCode": 307
  512. },
  513. /* 是否允许跨域访问,默认true */
  514. "allowAnyOrigin": true,
  515. /* 把请求的ip地址、端口号复制到请求头中的前缀。若不指定则不复制。 */
  516. "prefixOfCopyIpToHeader": "Sers-Gateway-",
  517. /* http回应中的默认Content-Type。若不指定则默认为 "application/json; charset="+Serialization.Instance.charset */
  518. "//ResponseDefaultContentType": "application/json; charset=UTF-8",
  519. /* 映射静态文件。若不指定则不映射静态文件 */
  520. "staticFiles": {
  521. /* 请求路径(可不指定)。demo:"/file/static"。The relative request path that maps to static resources */
  522. //"requestPath": "/file",
  523. /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则为默认路径(wwwroot)。demo:"wwwroot/demo" */
  524. //"rootPath": "wwwroot",
  525. /* 默认页面(可不指定)。An ordered list of file names to select by default. List length and ordering may affect performance */
  526. "defaultFileNames": [ "index.html" ],
  527. /* 是否可浏览目录(default false)。Enables directory browsing */
  528. //"useDirectoryBrowser": false,
  529. /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
  530. "contentTypeMapFile": "contentTypeMap.json",
  531. /* 回应静态文件时额外添加的http回应头。可不指定。 */
  532. "responseHeaders": {
  533. //设置浏览器静态文件缓存3600秒
  534. "Cache-Control": "public,max-age=3600"
  535. }
  536. }
  537. },
  538. //调用api前的事件,可不指定
  539. "BeforeCallApi": [
  540. {
  541. /* 在此Assembly中加载类 */
  542. "assemblyFile": "Sers.Core.dll",
  543. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  544. //"className": "Bearer",
  545. //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  546. /* 验证at接口的地址 */
  547. "api_verifyAt": "/AuthCenter/account/verifyAt",
  548. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  549. "api_httpMethod": "POST"
  550. },
  551. {
  552. /* 在此Assembly中加载类 */
  553. "assemblyFile": "Sers.Core.Module.Api.ApiEvent.BeforeCallApi.JsonWebToken.dll",
  554. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  555. //"className": "Sers.Core.Module.Api.ApiEvent.BeforeCallApi.JsonWebToken.JsonWebToken",
  556. //在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),或cookie中的Authorization, 并把jwt中的Claims信息放到 rpcData.user.userInfo
  557. // if token is valid, will set rpcData.caller.source to CallerSource
  558. "CallerSource": "Internal",
  559. //"issuer": "https://sso.lith.cloud:4",
  560. //"audiences": [ "http://localhost:4580" ],
  561. "publicKeysDiscovery_Url": "https://sso.lith.cloud:4/oauth2/v1/discovery/keys"
  562. },
  563. {
  564. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  565. "className": "AccountInCookie",
  566. "account": [
  567. {
  568. "userToken": "admin_123456",
  569. "CallerSource": "Internal",
  570. "userInfo": {
  571. "name": "Gover管理员",
  572. "入口": "Gover网关"
  573. }
  574. }
  575. ]
  576. }
  577. ],
  578. /* 服务限流配置,可不指定 */
  579. "rateLimit": [
  580. {
  581. /* 服务限流key,标识一个限流服务,必须唯一 */
  582. "rateLimitKey": "rate",
  583. /* 固定时间窗口限流。在单位时间(msInterval)内限制最大请求数量为reqLimit。超出数量的请求将被拒绝 */
  584. "rateLimitType": "FixedWindow",
  585. /* 单位时间内最大请求数量(个)*/
  586. "reqLimit": 100000,
  587. /* 单位时间长度(单位:ms)*/
  588. "msInterval": 1000
  589. }
  590. ]
  591. }
  592. },
  593. /* Vit工具配置,可不指定 */
  594. "Vit": {
  595. /* 日志配置,可不指定 */
  596. "Logger": {
  597. /* print the log to Log/*.txt default:true */
  598. "PrintToTxt": true,
  599. /* print the log to console. default:true */
  600. "PrintToConsole": true,
  601. /* [optional]collector to send log to */
  602. "Collector": [
  603. {
  604. /* 在此Assembly中加载类 */
  605. "assemblyFile": "Vit.Core.dll",
  606. /* 动态加载的类名,必须继承接口 Vit.Core.Module.Log.LogCollector.ILogCollector */
  607. //"className": "Vit.Core.Module.Log.LogCollector.Splunk.SplunkCollector",
  608. "server": {
  609. "url": "https://192.168.20.20:8088/services/collector",
  610. "authToken": "xxxxx",
  611. "index": "dev",
  612. //若指定则在指定时间间隔统一推送数据,若不指定则立即推送。单位:ms
  613. "//intervalMs": 2000
  614. },
  615. "//hostInfo": {
  616. "host": "192.168.20.20:8088",
  617. "source": "http:mc",
  618. "sourcetype": "httpevent"
  619. },
  620. //custome object
  621. "//appInfo": {
  622. "namespace": "sers.cloud",
  623. "appName": "mc",
  624. "moduleName": "ServiceCenter"
  625. //,"...": {}
  626. }
  627. },
  628. {
  629. /* 在此Assembly中加载类 */
  630. "assemblyFile": "Vit.Core.dll",
  631. /* 动态加载的类名,必须继承接口 Vit.Core.Module.Log.LogCollector.ILogCollector */
  632. //"className": "Vit.Core.Module.Log.LogCollector.ElasticSearch.ElasticSearchCollector",
  633. "server": {
  634. // es address, example:"http://192.168.20.20:9200"
  635. "url": "http://192.168.20.20:9200",
  636. //es index, example:"dev"
  637. "index": "dev_log",
  638. //es type, example:"_doc"
  639. //"type": "_doc",
  640. //若指定则在指定时间间隔统一推送数据,若不指定则立即推送。单位:ms
  641. "//intervalMs": 2000
  642. },
  643. //custome object
  644. "appInfo": {
  645. "namespace": "sers.cloud",
  646. "appName": "mc",
  647. "moduleName": "ServiceCenter"
  648. //,"...": {}
  649. }
  650. }
  651. ]
  652. },
  653. /* 序列化配置,可不指定 */
  654. "Serialization": {
  655. /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */
  656. "Encoding": "UTF8",
  657. /* 时间序列化格式。可不指定,默认 "yyyy-MM-dd HH:mm:ss" */
  658. "DateTimeFormat": "yyyy-MM-dd HH:mm:ss"
  659. },
  660. "//Kestrel": {
  661. /* (int64) the maximum allowed size of any request body in bytes. When set to null, the maximum request body size is unlimited. */
  662. "MaxRequestBodySize": 2000000000,
  663. /* (int32) A limit on the length of individual form values. Forms containing values that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
  664. "ValueLengthLimit": 2000000000,
  665. /* (int64) A limit for the length of each multipart body. Forms sections that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
  666. "MultipartBodyLengthLimit": 2000000000
  667. }
  668. },
  669. /* 若不指定,则不输出aspnet日志到控制台输出 */
  670. "Logging": {
  671. "LogLevel": {
  672. "Default": "Warning"
  673. }
  674. }
  675. }