Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

将 core 包模块化为子项目 morny-system-lib 或 morny-core,以增加共用可能性 #46

Open
Eyre-S opened this issue Oct 27, 2024 · 3 comments
Labels
19%source#structure about the system structure.

Comments

@Eyre-S
Copy link
Owner

Eyre-S commented Oct 27, 2024

目前预计可以将这个完全在一起的项目分离为以下几个部分:

  • morny-system-libmorny-core: 包含 MornyCoeur 关键系统以及 SystemMain, ModuleLoader 等入口点,以及 bot, http, log 等公共 API 部分,可以被完全重用。也可能包含 MornyReports, MornyInformation, MornyManagers 等非关键系统但是仍然有比较高的可重用价值的部分,这一部分也可能会重新分更细粒度的包。
  • morny-coeur: 包含目前 Morny 的所有功能实现,但是没有关键系统组件。
@Eyre-S Eyre-S added the 19%source#structure about the system structure. label Oct 27, 2024
@Eyre-S
Copy link
Owner Author

Eyre-S commented Oct 27, 2024

目前的计划是将 core 包和 data 包转移至 morny-system-lib 子项目。

morny.core 包大概会变为 morny.systemmorny.data 会变为 morny.system.data,一些需要的 utils 也会移动进来(或者在 da4a 项目中实现)

@Eyre-S Eyre-S moved this from Waiting to In Design in Morny Following... Oct 27, 2024
@Eyre-S
Copy link
Owner Author

Eyre-S commented Oct 27, 2024

为实现这个迁移,目前 core 部分有两个地方依赖了非 core 组件。两个部分都是依赖了 MornyReport 非关键但是系统耦合度较高的组件,目前都可以通过对两个依赖点进行事件化来反转依赖关系解决。

cc.sukazyo.cono.morny.core.MornyCoeur

对于自定义内部 GetUpdates Exception 的地方,为了向 Telegram 端报告错误而依赖了 MornyReport

s"""Failed get updates: ${e.getMessage}
| server responses:
|${GsonBuilder().setPrettyPrinting().create.toJson(e.response).indent(4)}
|""".stripMargin
externalContext.consume[MornyReport](_.exception(e, "Failed get updates."))

case e_other =>
logger `error`
s"""Failed get updates:
|${e_other.toLogString `indent` 3}""".stripMargin
externalContext.consume[MornyReport](_.exception(e_other, "Failed get updates."))

cc.sukazyo.cono.morny.core.bot.api.EventListenerManager

对于事件监听器抛出的异常的处理,为了向 Telegram 端报告错误而依赖了 MornyReport:

val errorMessage = StringBuilder()
errorMessage ++= "Event throws unexpected exception:\n"
errorMessage ++= (e.toLogString `indent` 4)
e match
case actionFailed: EventRuntimeException.ActionFailed =>
errorMessage ++= "\ntg-api action: response track: "
errorMessage ++= (GsonBuilder().setPrettyPrinting().create().toJson(
actionFailed.response
) `indent` 4) ++= "\n"
case _ =>
logger `error` errorMessage.toString
coeur.externalContext.consume[MornyReport](_.exception(e, "on event running"))

@Eyre-S
Copy link
Owner Author

Eyre-S commented Oct 27, 2024

cc.sukazyo.cono.morny.core.MornyCoeur

对于自定义内部 GetUpdates Exception 的地方,为了向 Telegram 端报告错误而依赖了 MornyReport

这一部分可以通过添加 TelegramBot.GetUpdateErrorEvent 解决。

cc.sukazyo.cono.morny.core.bot.api.EventListenerManager

对于事件监听器抛出的异常的处理,为了向 Telegram 端报告错误而依赖了 MornyReport:

可以通过添加 TelegramEventManager.UnhandledListenerExceptionThrownEvent 解决。

这几个名称目前都只是暂定,可能会随着未来事件系统的进一步设计和完善而改变。

#51

@Eyre-S Eyre-S closed this as completed Oct 27, 2024
@github-project-automation github-project-automation bot moved this from In Design to Done in Morny Following... Oct 27, 2024
@Eyre-S Eyre-S reopened this Oct 27, 2024
@github-project-automation github-project-automation bot moved this from Done to Todo in Morny Following... Oct 27, 2024
@Eyre-S Eyre-S moved this from Todo to In Design in Morny Following... Oct 27, 2024
@Eyre-S Eyre-S added this to the 2.0 - Morny Xinzheng milestone Oct 27, 2024
@Eyre-S Eyre-S moved this from In Design to In Progress in Morny Following... Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
19%source#structure about the system structure.
Projects
Status: In Progress
Development

No branches or pull requests

1 participant