本文整理汇总了TypeScript中dubbo2.js.setting类的典型用法代码示例。如果您正苦于以下问题:TypeScript js.setting类的具体用法?TypeScript js.setting怎么用?TypeScript js.setting使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了js.setting类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: default
export default (app: EggApplication) => {
const dubboSetting = setting
.match(
[
'com.alibaba.dubbo.demo.DemoProvider',
'com.alibaba.dubbo.demo.ErrorProvider',
],
{
version: '1.0.0',
},
)
.match('com.alibaba.dubbo.demo.BasicTypeProvider', {version: '2.0.0'});
const dubbo = new Dubbo<typeof service>({
application: {name: 'node-egg-bff'},
register: 'localhost:2181',
service,
dubboSetting,
});
// extends middleware
dubbo.use(async (ctx: Context, next: any) => {
const start = Date.now();
await next();
const end = Date.now();
app.coreLogger.info(
`${ctx.dubboInterface} was invoked, cost-time ${end - start}`,
);
});
app.dubbo = dubbo;
};
示例2: test
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Dubbo, java, setting} from 'dubbo2.js';
import {DemoProvider} from './providers/com/alibaba/dubbo/demo/DemoProvider';
import {UserRequest} from './providers/com/alibaba/dubbo/demo/UserRequest';
const service = {
DemoProvider,
};
const dubboSetting = setting
.match('com.alibaba.dubbo.demo.BasicTypeProvider', {
version: '2.0.0',
})
.match('com.alibaba.dubbo.demo.DemoProvider', {version: '1.0.0'})
.match('com.alibaba.dubbo.demo.ErrorProvider', {version: '1.0.0'});
const dubbo = new Dubbo<typeof service>({
application: {name: '@qianmi/node-dubbo'},
register: 'localhost:2181',
dubboInvokeTimeout: 0.001,
service,
dubboSetting,
});
//use middleware
dubbo.use(async function test(ctx, next) {
const startTime = Date.now();