前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Main idea of OPA design - 2446

Main idea of OPA design - 2446

作者头像
Jerry Wang
发布2019-06-14 10:34:36
4000
发布2019-06-14 10:34:36
举报

Creative Commons

It helps us a lot to resolve OPA issue if we understand the logic of OPA implementation thoroughly. Take my Lead OPA for example, in our test case implementation, we simply design several command and execute them ![clipboard1](https://user-images.githubusercontent.com/5669954/59409490-ebd45100-8de8-11e9-9036-8321d1ac5f65.png) All those command simply assemble an object and delegate to waitFor function: ![clipboard2](https://user-images.githubusercontent.com/5669954/59409495-ec6ce780-8de8-11e9-86b8-1f6e0cc782b2.png) The waitFor implementation is the essential part of OPA engine. The parameter passed through waitFor is simply inserted to an internal queue maintained by OPA engine. For every item inserted in the queue, besides the properties specified in our test code, there are some additional default properties like timeout : 15 seconds and pollingInterval: 400 milliseconds. ![clipboard3](https://user-images.githubusercontent.com/5669954/59409496-ed057e00-8de8-11e9-8d53-5c8d1812e304.png) For the test case "Add Lead View Test1", there are totally 29 items in the queue to be executed one by one. You can check queue content from variable queue in line 298 below. ![clipboard4](https://user-images.githubusercontent.com/5669954/59409497-ed057e00-8de8-11e9-98b4-32c5ca7571a8.png) Remember, our test code will never immediately trigger OPA execution. Instead, the code will just insert directive into queue and return. The real OPA execution is triggered by Opa.emptyQueue, see line 73 below. The directive in the head of queue is fetched via Array.prototype.shift, and internal polling is started via internalWait. ![clipboard5](https://user-images.githubusercontent.com/5669954/59409498-ed9e1480-8de8-11e9-8a05-98d5888a5ef7.png) And below is the core of OPA queue handling engine: ![clipboard6](https://user-images.githubusercontent.com/5669954/59409499-ed9e1480-8de8-11e9-9aca-1846673d4201.png) When you study OPA source code, you will meet with many usage of promise & resolve & reject in the source code, this is also the case in our latest UI5 framework. See this article for more detail.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年06月13日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档