sof3/await-rt 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sof3/await-rt

Composer 安装命令:

composer require sof3/await-rt

包简介

README 文档

README

await-rt is the low-level runtime of the await-generator library. See the await-generator repo or the book for beginner-level introduction.

Specification

await-rt executes generators that conform to the await-generator protocol:

  • The state transition of a generator:
    • A generator must not start executing until it is passed to Await::run().
    • When passed to Await::run(), the generator enters the running state. It immediately rewinds and synchronously executes until its first suspension point. The control flow will be returned to the caller of Await::run() eventually.
    • When a generator in any state suspends with the string "identity", it is synchronously resumed with an object of arbitrary class unique to the Await::run() call that rewinded the generator.
    • When a generator in running state suspends with the string "resolve", it is synchronously resumed with a "resolve closure" of type Closure(value=): void. The generator state changes to scheduling/single.
    • When a generator in scheduling/single state suspends with the string "reject", it is synchronously resumed with a "reject closure" of type Closure(Throwable): void. The generator state changes to scheduling/double.
    • When a generator in scheduling/single or scheduling/double state suspends with the string "once", the generator state changes to pending and is not actively resumed.
    • When a generator is in scheduling/single or scheduling/double state and the resolve closure is invoked, the generator state changes to ready/single or ready/double. Since the generator is supposed to be executing in the scheduling state, the closure returns normally, returning the control flow to the generator.
    • When a generator is in scheduling/double state and the reject closure is invoked, the generator state changes to failed. Since the generator is supposed to be executing in the scheduling state, the closure returns normally, returning the control flow to the generator.
    • When a generator is in ready/single or ready/double state and suspends with the string "once", the generator state changes to running, and the generator is synchronously resumed with the value previously passed to the resolve closure (or null if none passed).
    • When a generator is in failed state and suspends with the string "once", the generator state changes to running, and the generator is synchronously interrupted with the throwable value previously passed to the reject closure. This is effectively the same as replacing yield "once" with throw $throwable.
    • When a generator is in pending state and the resolve closure is invoked, the generator is synchronously resumed with the value passed (or null if none passed). The control flow will be returned to the caller of the resolve closure eventually.
    • When a generator is in pending state and the reject closure is invoked, the generator is synchronously interrupted with the value passed (or null if none passed). The control flow will be returned to the caller of the reject closure eventually. no earlier than the next time the generatoe enters pending, return or throw state, but the exact moment is undefined.
    • When a generator is in runnning state and returns from the generator, control flow is returned to the eventual rewinds.
    • When a generator is in runnning state and throws out of the generator, control flow is returned to the eventual rewinds with an active exception throwing.
      • Note: This is different from await-generator v3, where the exeption would be wrapped with an AwaitException instead.
  • All state transitions not specified above results in throwing an exception of an arbitrary type that extends or equals \Exception.
  • Calling a resolve closure after the generator is resumed to the running state results in throwing an exception of an arbitrary type that extends or equals \Exception.
  • The terms eventually or eventual rewinds refer to the following: When the control flow is passed into the await runtime, i.e. through calling Await::run, resolve closure or reject closure, the exact moment or order that the control flow is returned to the caller is undefined, but is guaranteed to take place eventually provided that the generator does not actively trigger any code that blocks indefinitely. However, it is guaranteed that, if there are no other callers, if the generator enters running state and then return or throw immediately, the control flow is immediately returned to the caller.
stateDiagram
    [*] --> running: Await..run
    running --> scheduling/single: yield "resolve"
    scheduling/single --> scheduling/double: yield "reject"
    scheduling/single --> ready/single: invoke resolve closure
    scheduling/double --> ready/double: invoke resolve closure
    scheduling/double --> fail: invoke reject closure
    ready/single --> ready/double: yield "reject"
    scheduling/single --> pending: yield "once"
    scheduling/double --> pending: yield "once"
    ready/single --> running: yield "once"
    ready/double --> running: yield "once"
    failed --> running: yield "once"
    pending --> running: invoke resolve closure\ninvoke reject closure
    running --> [*]: return
    running --> [*]: throw
Loading

sof3/await-rt 适用场景与选型建议

sof3/await-rt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 5, 最近一次更新时间为 2023 年 09 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 sof3/await-rt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sof3/await-rt 我们能提供哪些服务?
定制开发 / 二次开发

基于 sof3/await-rt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2023-09-04