appsettings.json 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. {
  2. /* Sers微服务配置 */
  3. "Sers": {
  4. /* 通讯层配置 */
  5. "CL": {
  6. /* 共用配置,子项共用,覆写子项未指定的配置 */
  7. "Config": {
  8. "workThread": {
  9. // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
  10. "mode": "LongThread",
  11. /* 后台处理消息的线程个数(单位个,默认2) */
  12. "threadCount": 2,
  13. /* 请求超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
  14. "timeoutMs": 300000
  15. },
  16. /* 请求超时时间(单位ms,默认300000) */
  17. "requestTimeoutMs": 300000,
  18. //HeartBeat
  19. /* 心跳检测时间间隔(单位ms,默认10000,若指定为0则不进行心跳检测) */
  20. "heartBeatIntervalMs": 10000,
  21. /* 心跳检测超时时间(单位ms,默认30000) */
  22. "heartBeatTimeoutMs": 30000,
  23. /* 心跳检测失败重试次数(单位次,默认10) */
  24. "heartBeatRetryCount": 10,
  25. /* 数据传输 加密协议,可多个,可不指定 */
  26. "//security": [
  27. {
  28. // SampleSecurity
  29. /* 在此Assembly中查找security */
  30. "assemblyFile": "Sers.Core.dll",
  31. /* the class of security in assemblyFile. 必须继承接口 Sers.Core.Util.StreamSecurity.ISecurity */
  32. "className": "Sers.Core.Util.StreamSecurity.Security.SampleSecurity",
  33. /* (x.2) config */
  34. /* 加密密钥 */
  35. "secret": "security"
  36. },
  37. {
  38. // SampleSecurity
  39. /* 若不指定assemblyFile和className 则默认为Sers.Core.Util.StreamSecurity.Security.SampleSecurity */
  40. "secret": "Two layer encryption"
  41. }
  42. ],
  43. /* 连接秘钥,用以验证连接安全性。服务端和客户端必须一致 */
  44. "secretKey": "SersCL"
  45. },
  46. /* one conn is one channel.can be multiable */
  47. "Client": [
  48. {
  49. // Ipc.NamedPipe
  50. /* (x.1) type */
  51. /* 在此Assembly中查找builder */
  52. "assemblyFile": "Sers.CL.Ipc.NamedPipe.dll",
  53. /* the class of builder in assemblyFile */
  54. //"className": "Sers.CL.Ipc.NamedPipe.OrganizeClientBuilder",
  55. /* (x.2) config */
  56. // 命名管道只支持本机或局域网。
  57. /* 服务端机器名或者ip地址(如 103.23.23.23 、win10f),默认 "." */
  58. "serverName": ".",
  59. /* 命名管道名称。例如: "Sers.CL.Ipc" */
  60. "pipeName": "Sers.CL.Ipc.4501"
  61. },
  62. {
  63. // Socket.Iocp
  64. /* (x.1) type - Iocp */
  65. /* 在此Assembly中查找builder */
  66. //"assemblyFile": "Sers.CL.Socket.Iocp.dll",
  67. /* the class of builder in assemblyFile */
  68. "className": "Sers.CL.Socket.Iocp.OrganizeClientBuilder",
  69. /* 通信模式(默认值:Simple)。可为 Simple、Timer、ThreadWait */
  70. //"mode": "ThreadWait",
  71. /* 接收缓存区大小(单位:byte,默认:8192) */
  72. //"receiveBufferSize": 8192,
  73. /* 发送缓冲区刷新间隔(单位:毫秒,默认:1)(仅当mode为Timer和ThreadWait时有效) */
  74. //"sendFlushInterval": 1,
  75. /* 发送缓冲区数据块的最小大小(单位:byte,默认 1000000)(仅当mode为Timer和ThreadWait时有效) */
  76. //"sendBufferSize": 1000000,
  77. /* 发送缓冲区个数(默认1024)(仅当mode为Timer和ThreadWait时有效) */
  78. //"sendBufferCount": 1024,
  79. /* (x.2) config */
  80. /* 服务端 host地址。例如: "127.0.0.1"、"sers.cloud" */
  81. "host": "127.0.0.1",
  82. /* 服务端 监听端口号。例如: 4501 */
  83. "port": 4501
  84. },
  85. {
  86. // Socket.ThreadWait
  87. /* (x.1) type - ThreadWait */
  88. /* the class of builder in assemblyFile */
  89. //"className": "Sers.CL.Socket.ThreadWait.OrganizeClientBuilder",
  90. /* (x.2) config */
  91. /* 服务端 host地址。例如: "127.0.0.1"、"sers.cloud" */
  92. "host": "127.0.0.1",
  93. /* 服务端 监听端口号。例如: 4501 */
  94. "port": 4501
  95. },
  96. {
  97. // Zmq.ThreadWait
  98. /* (x.1) type */
  99. /* 在此Assembly中查找builder */
  100. "assemblyFile": "Sers.CL.ClrZmq.ThreadWait.dll",
  101. /* the class of builder in assemblyFile */
  102. //"className": "Sers.CL.ClrZmq.ThreadWait.OrganizeClientBuilder",
  103. /* (x.2) config */
  104. /* 地址。例如: "tcp://127.0.0.1:4502" 、 "ipc://4502" */
  105. "endpoint": "tcp://127.0.0.1:4502"
  106. },
  107. {
  108. // WebSocket
  109. /* (x.1) type - WebSocket */
  110. /* 在此Assembly中查找builder */
  111. "assemblyFile": "Sers.CL.WebSocket.dll",
  112. /* the class of builder in assemblyFile */
  113. //"className": "Sers.CL.WebSocket.OrganizeClientBuilder",
  114. /* (x.2) config */
  115. /* 服务端地址(默认为 "ws://127.0.0.1:4503") */
  116. "host": "ws://127.0.0.1:4503"
  117. },
  118. {
  119. // Zmq.FullDuplex
  120. /* (x.1) type */
  121. /* 在此Assembly中查找builder */
  122. "assemblyFile": "Sers.CL.Zmq.FullDuplex.dll",
  123. /* the class of builder in assemblyFile */
  124. //"className": "Sers.CL.Zmq.FullDuplex.OrganizeClientBuilder",
  125. /* (x.2) config */
  126. /* 地址。例如: "tcp://127.0.0.1:4504" 、 "ipc://4504" */
  127. "endpoint": "tcp://127.0.0.1:4504"
  128. },
  129. {
  130. // Ipc.SharedMemory
  131. /* (x.1) type - Ipc.SharedMemory */
  132. /* 在此Assembly中查找builder */
  133. "assemblyFile": "Sers.CL.Ipc.SharedMemory.dll",
  134. /* the class of builder in assemblyFile */
  135. //"className": "Sers.CL.Ipc.SharedMemory.OrganizeClientBuilder",
  136. /* (x.2) config */
  137. /* 共享内存名称。例如: "ipcTest" */
  138. "name": "ipcForStationDemo"
  139. }
  140. ]
  141. },
  142. // RpcData序列化模式。可不指定。默认为Text。
  143. // 可为 Newtonsoft、Text、BytePointor。
  144. // 效率依次递增。BytePointor 序列化为二进制数据而不是json字符串。
  145. "RpcDataSerializeMode": "Text",
  146. /* LocalApiService 配置,可不指定 */
  147. "LocalApiService": {
  148. /* 是否 输出本地Api的调用信息到(ApiTrace)Log文件。默认:false */
  149. "PrintTrace": false,
  150. "workThread": {
  151. // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
  152. "mode": "LongThread",
  153. /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
  154. "threadCount": 16,
  155. /* 请求超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
  156. "timeoutMs": 300000
  157. },
  158. /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */
  159. "//staticFiles": [
  160. {
  161. /* api路由前缀,例如 "/demo/ui/*" */
  162. "route": "/demo/ui/*",
  163. /* api描述,静态文件描述 */
  164. "apiName": "demo站点静态文件",
  165. /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录。demo:"wwwroot/demo" */
  166. "rootPath": "wwwroot/demo",
  167. /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
  168. "contentTypeMapFile": "contentTypeMap.json",
  169. /* 回应静态文件时额外添加的http回应头。可不指定。 */
  170. "responseHeaders": {
  171. //设置浏览器静态文件缓存3600秒
  172. "Cache-Control": "public,max-age=3600"
  173. }
  174. }
  175. ],
  176. /* 默认站点名称,可多个,可不指定 */
  177. "apiStationNames": [ "demo" ],
  178. /* Api加载器配置 */
  179. "//ApiLoaders": [
  180. {
  181. /* 在此Assembly中查找api加载器(如 Sers.Core.dll 、Sers.NetcoreLoader.dll 、 Sers.Serslot.dll ) */
  182. //"loader_assemblyFile": "Sers.Core.dll",
  183. /* 加载器的类名,可为 Sers.SersLoader.ApiLoader 、 Sers.NetcoreLoader.ApiLoader、 Sers.Serslot.ApiLoader 等。若不指定则默认为"Sers.SersLoader.ApiLoader" */
  184. //"loader_className": "Sers.SersLoader.ApiLoader",
  185. //(通过反射从此包中获取要加载的api)
  186. /* 在此Assembly中查找服务(如 Did.SersLoader.Demo.dll)(assembly、assemblyFile、assemblyName 指定任一即可) */
  187. "assemblyFile": "Did.SersLoader.Demo.dll",
  188. /* 在此Assembly中查找服务(如 Did.SersLoader.Demo)(assembly、assemblyFile、assemblyName 指定任一即可) */
  189. //"assemblyName": "Did.SersLoader.Demo",
  190. /* 强制指定ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  191. //"apiStationName_Force": "",
  192. /* ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
  193. "apiStationName": "demo"
  194. /* 强制路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低: routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix) */
  195. //"routePrefix_Force": "",
  196. /* 路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低: routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix ) */
  197. //"routePrefix": ""
  198. }
  199. ],
  200. /* 调用Api时的自定义Scope对象。可不指定。事件顺序为 OnCreateScope -> BeforeCallApi -> OnDispose */
  201. "//OnCreateScope": [
  202. {
  203. /* 在此Assembly中加载类 */
  204. "assemblyFile": "Sers.ApiTrace.dll",
  205. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.ApiScope.IApiScopeEvent */
  206. "className": "Sers.ApiTrace.ApiScope"
  207. }
  208. ],
  209. /* 调用api前的事件,可不指定。事件顺序为 OnCreateScope -> BeforeCallApi -> OnDispose */
  210. "//BeforeCallApi": [
  211. {
  212. /* 在此Assembly中加载类 */
  213. //"assemblyFile": "Sers.Core.dll",
  214. /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
  215. "className": "Bearer",
  216. //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
  217. /* 验证at接口的地址 */
  218. "api_verifyAt": "/AuthCenter/account/verifyAt",
  219. /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
  220. "api_httpMethod": "POST"
  221. },
  222. {
  223. //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
  224. "className": "AccountInCookie",
  225. "account": [
  226. {
  227. "userToken": "admin_123456",
  228. //"CallerSource": "Internal",
  229. "userInfo": {
  230. "name": "超级管理员",
  231. "入口": "Gover网关"
  232. }
  233. }
  234. ]
  235. }
  236. ]
  237. },
  238. /* ServiceStation配置,可不指定 */
  239. "ServiceStation": {
  240. /* 自动上报cpu Usage。不指定则不上报 */
  241. "//UsageReporter": {
  242. /* 上报时间间隔(单位:秒) */
  243. "intervalSecond": 2
  244. },
  245. /* 服务中心注册配置。在向服务中心注册站点前 是否打印(Logger.Info)请求参数。默认:false */
  246. "StationRegist_PrintRegistArg": false,
  247. /* serviceStation站点信息,可不指定 */
  248. "serviceStationInfo": {
  249. /* 服务站点名称 */
  250. "serviceStationName": "demo",
  251. /* 服务站点版本信息,若不指定则为入口链接库的版本号 */
  252. //"stationVersion": "1.1.9.0",
  253. /* [json]服务站点额外信息,可不指定 */
  254. "info": null
  255. }
  256. }
  257. },
  258. "Demo": {
  259. /* 映射静态文件 */
  260. "staticFiles": {
  261. /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录。demo:"wwwroot/demo" */
  262. "rootPath": "wwwroot/demo",
  263. /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
  264. "contentTypeMapFile": "contentTypeMap.json",
  265. /* 回应静态文件时额外添加的http回应头。可不指定。 */
  266. "responseHeaders": {
  267. //设置浏览器静态文件缓存3600秒
  268. "Cache-Control": "public,max-age=3600"
  269. }
  270. }
  271. },
  272. /* Vit工具配置,可不指定 */
  273. "Vit": {
  274. /* 日志配置,可不指定 */
  275. "Logger": {
  276. /* print the log to Log/*.txt default:true */
  277. "PrintToTxt": true,
  278. /* print the log to console. default:true */
  279. "PrintToConsole": true
  280. },
  281. /* 序列化配置,可不指定 */
  282. "Serialization": {
  283. /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */
  284. "Encoding": "UTF8",
  285. /* 时间序列化格式。可不指定,默认 "yyyy-MM-dd HH:mm:ss" */
  286. "DateTimeFormat": "yyyy-MM-dd HH:mm:ss"
  287. }
  288. }
  289. }