{ /* Sers微服务配置 */ "Sers": { /* 通讯层配置 */ "CL": { /* 共用配置,子项共用,覆写子项未指定的配置 */ "Config": { "workThread": { // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade "mode": "LongThread", /* 后台处理消息的线程个数(单位个,默认2) */ "threadCount": 2, /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */ "maxThreadCount": 100, /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */ "pendingQueueLength": 100000, /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */ "timeoutMs": 300000 }, /* 请求超时时间(单位ms,默认300000) */ "requestTimeoutMs": 300000, //HeartBeat /* 心跳检测时间间隔(单位ms,默认10000,若指定为0则不进行心跳检测) */ "heartBeatIntervalMs": 10000, /* 心跳检测超时时间(单位ms,默认30000) */ "heartBeatTimeoutMs": 30000, /* 心跳检测失败重试次数(单位次,默认10) */ "heartBeatRetryCount": 10, /* 数据传输 加密协议,可多个,可不指定 */ "//security": [ { // SampleSecurity /* 在此Assembly中查找security */ "assemblyFile": "Sers.Core.dll", /* the class of security in assemblyFile. 必须继承接口 Sers.Core.Util.StreamSecurity.ISecurity */ "className": "Sers.Core.Util.StreamSecurity.Security.SampleSecurity", /* (x.2) config */ /* 加密密钥 */ "secret": "security" }, { // SampleSecurity /* 若不指定assemblyFile和className 则默认为Sers.Core.Util.StreamSecurity.Security.SampleSecurity */ "secret": "Two layer encryption" } ], /* 连接秘钥,用以验证连接安全性。服务端和客户端必须一致 */ "secretKey": "SersCL" }, /* one conn is one channel.can be multiable */ "Client": [ { // Ipc.NamedPipe /* (x.1) type */ /* 在此Assembly中查找builder */ "assemblyFile": "Sers.CL.Ipc.NamedPipe.dll", /* the class of builder in assemblyFile */ //"className": "Sers.CL.Ipc.NamedPipe.OrganizeClientBuilder", /* (x.2) config */ // 命名管道只支持本机或局域网。 /* 服务端机器名或者ip地址(如 103.23.23.23 、win10f),默认 "." */ "serverName": ".", /* 命名管道名称。例如: "Sers.CL.Ipc" */ "pipeName": "Sers.CL.Ipc.4501" }, { // Socket.Iocp /* (x.1) type - Iocp */ /* 在此Assembly中查找builder */ //"assemblyFile": "Sers.CL.Socket.Iocp.dll", /* the class of builder in assemblyFile */ "className": "Sers.CL.Socket.Iocp.OrganizeClientBuilder", /* 通信模式(默认值:Simple)。可为 Simple、Timer、ThreadWait */ //"mode": "ThreadWait", /* 接收缓存区大小(单位:byte,默认:8192) */ //"receiveBufferSize": 8192, /* 发送缓冲区刷新间隔(单位:毫秒,默认:1)(仅当mode为Timer和ThreadWait时有效) */ //"sendFlushInterval": 1, /* 发送缓冲区数据块的最小大小(单位:byte,默认 1000000)(仅当mode为Timer和ThreadWait时有效) */ //"sendBufferSize": 1000000, /* 发送缓冲区个数(默认1024)(仅当mode为Timer和ThreadWait时有效) */ //"sendBufferCount": 1024, /* (x.2) config */ /* 服务端 host地址。例如: "127.0.0.1"、"sers.cloud" */ "host": "127.0.0.1", /* 服务端 监听端口号。例如: 4501 */ "port": 4501 }, { // Socket.ThreadWait /* (x.1) type - ThreadWait */ /* the class of builder in assemblyFile */ //"className": "Sers.CL.Socket.ThreadWait.OrganizeClientBuilder", /* (x.2) config */ /* 服务端 host地址。例如: "127.0.0.1"、"sers.cloud" */ "host": "127.0.0.1", /* 服务端 监听端口号。例如: 4501 */ "port": 4501 }, { // Zmq.ThreadWait /* (x.1) type */ /* 在此Assembly中查找builder */ "assemblyFile": "Sers.CL.ClrZmq.ThreadWait.dll", /* the class of builder in assemblyFile */ //"className": "Sers.CL.ClrZmq.ThreadWait.OrganizeClientBuilder", /* (x.2) config */ /* 地址。例如: "tcp://127.0.0.1:4502" 、 "ipc://4502" */ "endpoint": "tcp://127.0.0.1:4502" }, { // WebSocket /* (x.1) type - WebSocket */ /* 在此Assembly中查找builder */ "assemblyFile": "Sers.CL.WebSocket.dll", /* the class of builder in assemblyFile */ //"className": "Sers.CL.WebSocket.OrganizeClientBuilder", /* (x.2) config */ /* 服务端地址(默认为 "ws://127.0.0.1:4503") */ "host": "ws://127.0.0.1:4503" }, { // Zmq.FullDuplex /* (x.1) type */ /* 在此Assembly中查找builder */ "assemblyFile": "Sers.CL.Zmq.FullDuplex.dll", /* the class of builder in assemblyFile */ //"className": "Sers.CL.Zmq.FullDuplex.OrganizeClientBuilder", /* (x.2) config */ /* 地址。例如: "tcp://127.0.0.1:4504" 、 "ipc://4504" */ "endpoint": "tcp://127.0.0.1:4504" }, { // Ipc.SharedMemory /* (x.1) type - Ipc.SharedMemory */ /* 在此Assembly中查找builder */ "assemblyFile": "Sers.CL.Ipc.SharedMemory.dll", /* the class of builder in assemblyFile */ //"className": "Sers.CL.Ipc.SharedMemory.OrganizeClientBuilder", /* (x.2) config */ /* 共享内存名称。例如: "ipcTest" */ "name": "ipcForStationDemo" } ] }, // RpcData序列化模式。可不指定。默认为Text。 // 可为 Newtonsoft、Text、BytePointor。 // 效率依次递增。BytePointor 序列化为二进制数据而不是json字符串。 "RpcDataSerializeMode": "Text", /* LocalApiService 配置,可不指定 */ "LocalApiService": { /* 是否 输出本地Api的调用信息到(ApiTrace)Log文件。默认:false */ "PrintTrace": false, "workThread": { // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade "mode": "LongThread", /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */ "threadCount": 16, /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */ "maxThreadCount": 100, /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */ "pendingQueueLength": 100000, /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */ "timeoutMs": 300000 }, /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */ "//staticFiles": [ { /* api路由前缀,例如 "/demo/ui/*" */ "route": "/demo/ui/*", /* api描述,静态文件描述 */ "apiName": "demo站点静态文件", /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录。demo:"wwwroot/demo" */ "rootPath": "wwwroot/demo", /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */ "contentTypeMapFile": "contentTypeMap.json", /* 回应静态文件时额外添加的http回应头。可不指定。 */ "responseHeaders": { //设置浏览器静态文件缓存3600秒 "Cache-Control": "public,max-age=3600" } } ], /* 默认站点名称,可多个,可不指定 */ "apiStationNames": [ "demo" ], /* Api加载器配置 */ "//ApiLoaders": [ { /* 在此Assembly中查找api加载器(如 Sers.Core.dll 、Sers.NetcoreLoader.dll 、 Sers.Serslot.dll ) */ //"loader_assemblyFile": "Sers.Core.dll", /* 加载器的类名,可为 Sers.SersLoader.ApiLoader 、 Sers.NetcoreLoader.ApiLoader、 Sers.Serslot.ApiLoader 等。若不指定则默认为"Sers.SersLoader.ApiLoader" */ //"loader_className": "Sers.SersLoader.ApiLoader", //(通过反射从此包中获取要加载的api) /* 在此Assembly中查找服务(如 Did.SersLoader.Demo.dll)(assembly、assemblyFile、assemblyName 指定任一即可) */ "assemblyFile": "Did.SersLoader.Demo.dll", /* 在此Assembly中查找服务(如 Did.SersLoader.Demo)(assembly、assemblyFile、assemblyName 指定任一即可) */ //"assemblyName": "Did.SersLoader.Demo", /* 强制指定ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */ //"apiStationName_Force": "", /* ApiStation名称。可不指定。(优先级从高到低: apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */ "apiStationName": "demo" /* 强制路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低: routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix) */ //"routePrefix_Force": "", /* 路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低: routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix ) */ //"routePrefix": "" } ], /* 调用Api时的自定义Scope对象。可不指定。事件顺序为 OnCreateScope -> BeforeCallApi -> OnDispose */ "//OnCreateScope": [ { /* 在此Assembly中加载类 */ "assemblyFile": "Sers.ApiTrace.dll", /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.ApiScope.IApiScopeEvent */ "className": "Sers.ApiTrace.ApiScope" } ], /* 调用api前的事件,可不指定。事件顺序为 OnCreateScope -> BeforeCallApi -> OnDispose */ "//BeforeCallApi": [ { /* 在此Assembly中加载类 */ //"assemblyFile": "Sers.Core.dll", /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */ "className": "Bearer", //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo /* 验证at接口的地址 */ "api_verifyAt": "/AuthCenter/account/verifyAt", /* 验证at接口的httpMethod。(如 GET POST 可不指定) */ "api_httpMethod": "POST" }, { //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo) "className": "AccountInCookie", "account": [ { "userToken": "admin_123456", //"CallerSource": "Internal", "userInfo": { "name": "超级管理员", "入口": "Gover网关" } } ] } ] }, /* ServiceStation配置,可不指定 */ "ServiceStation": { /* 自动上报cpu Usage。不指定则不上报 */ "//UsageReporter": { /* 上报时间间隔(单位:秒) */ "intervalSecond": 2 }, /* 服务中心注册配置。在向服务中心注册站点前 是否打印(Logger.Info)请求参数。默认:false */ "StationRegist_PrintRegistArg": false, /* serviceStation站点信息,可不指定 */ "serviceStationInfo": { /* 服务站点名称 */ "serviceStationName": "demo", /* 服务站点版本信息,若不指定则为入口链接库的版本号 */ //"stationVersion": "1.1.9.0", /* [json]服务站点额外信息,可不指定 */ "info": null } } }, "Demo": { /* 映射静态文件 */ "staticFiles": { /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录。demo:"wwwroot/demo" */ "rootPath": "wwwroot/demo", /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */ "contentTypeMapFile": "contentTypeMap.json", /* 回应静态文件时额外添加的http回应头。可不指定。 */ "responseHeaders": { //设置浏览器静态文件缓存3600秒 "Cache-Control": "public,max-age=3600" } } }, /* Vit工具配置,可不指定 */ "Vit": { /* 日志配置,可不指定 */ "Logger": { /* print the log to Log/*.txt default:true */ "PrintToTxt": true, /* print the log to console. default:true */ "PrintToConsole": true }, /* 序列化配置,可不指定 */ "Serialization": { /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */ "Encoding": "UTF8", /* 时间序列化格式。可不指定,默认 "yyyy-MM-dd HH:mm:ss" */ "DateTimeFormat": "yyyy-MM-dd HH:mm:ss" } } }