-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates the docs. See details in [workflow run]. [Workflow Run]: https://github.com/pluto-lang/website/actions/runs/7750987168 ------ *Automatically created via the 'update-docs' workflow*
- Loading branch information
1 parent
4f69fc6
commit 280c0c5
Showing
13 changed files
with
319 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
title: Architecture Reference | ||
date: 2024-02-01 | ||
--- | ||
|
||
# Architecture Reference | ||
|
||
The Architecture Reference (hereafter referred to as Arch Ref) is a product of the [deducer](./deducer.en.md). It represents the architecture of an application mapped to the cloud, including the cloud BaaS resource instances that the application needs to create, the event handling functions of the resource instances, and the relationships between the resource instances. | ||
|
||
Users can understand the architecture of the application from the Arch Ref and confirm whether the architecture meets their expectations. Pluto will automatically create cloud BaaS and FaaS resource instances based on the content of the Arch Ref, with minimized permission configuration. | ||
|
||
## Components | ||
|
||
The Arch Ref consists of three parts: resource instances, compute closures, and resource relationships. The following diagram shows the composition of the Arch Ref: | ||
|
||
![The composition of Arch Ref](../../../public/assets/arch-ref-composition.png) | ||
|
||
### Resource Instances | ||
|
||
A Resource Instance is a cloud resource instance that the application needs to create. It includes information such as the instance's ID, type, name, and parameters. | ||
|
||
_Note: The name and ID here may not match the ID generated at runtime, as the ID is also generated based on the resource name. During the deduction phase, the resource name corresponds to the variable name of the resource object, while the name of the resource object at runtime is determined by the parameters given by the user. For example, `router = new Router("name")`, in the generated Arch Ref, the name is router, but at runtime, the resource name will be name._ | ||
|
||
### Compute Closures | ||
|
||
A Compute Closure is typically an event handling function of a resource instance, such as a Queue subscriber or a Router path handling function. It includes the closure's ID and path information. | ||
|
||
The path information is the folder path where the closure is located after export, relative to the root directory of the application. If it's a TypeScript application, the compute closure folder is a Node.js module, containing an `index.ts` file and an `index.js` file generated by esbuild compilation and packaging. The `default` function exported in this module is the event handling function defined by the user. | ||
|
||
### Resource Relationships | ||
|
||
A Resource Relationship represents the relationship between resource instances, including the actor of the relationship, the type, operation, and parameters. | ||
|
||
The actor could be a resource instance or a compute closure. If it's a resource instance, the corresponding relationship type should be `Create`, and the corresponding operation should belong to the [Infra API](./sdk.zh-CN.md) of that resource type, indicating that the resource instance has called an Infra API to create another resource instance or compute closure. If it's a compute closure, the corresponding relationship type should be `MethodCall` or `PropertyAccess`, indicating that a Client API method or property of a resource instance has been called in the compute closure. | ||
|
||
The `Create` relationship guides Pluto to create and associate resource instances at compile time, the `MethodCall` relationship guides Pluto to configure appropriate permissions for the FaaS instance to which the compute closure belongs at compile time, and the `PropertyAccess` relationship guides Pluto to configure appropriate environment variables for the FaaS instance to which the compute closure belongs at compile time, enabling it to access the properties of the resource instance at runtime. | ||
|
||
<!-- | ||
```plantuml | ||
@startuml | ||
class Architecture { | ||
+resources: Resource[] | ||
+closures: Closure[] | ||
+relationships: Relationship[] | ||
+addResource(resource: Resource): void | ||
+findResource(resourceId: string): Resource | undefined | ||
+addClosure(closure: Closure): void | ||
+findClosure(closureId: string): Closure | undefined | ||
+findResourceOrClosure(entityId: string): Resource | Closure | undefined | ||
+addRelationship(relationship: Relationship): void | ||
+topoSort(): (Resource | Closure | Relationship)[] | ||
} | ||
class Resource { | ||
+id: string | ||
+name: string | ||
+type: string | ||
+parameters: Parameter[] | ||
} | ||
class Closure { | ||
+id: string | ||
+path: string | ||
} | ||
class Relationship { | ||
+from: IDWithType | ||
+to: IDWithType[] | ||
+type: "Create" | "MethodCall" | "PropertyAccess" | ||
+operation: string | ||
+parameters: Parameter[] | ||
} | ||
class Parameter { | ||
+index: string | ||
+name: string | ||
+type: "closure" | "text" | ||
+value: string | ||
} | ||
class IDWithType { | ||
+id: string | ||
+type: "closure" | "resource" | ||
} | ||
' Relationships | ||
Architecture "1" *-- "*" Resource : contains | ||
Architecture "1" *-- "*" Closure : contains | ||
Architecture "1" *-- "*" Relationship : contains | ||
Resource "1" *-- "*" Parameter : contains | ||
Relationship "1" *-- "*" Parameter : contains | ||
Relationship "1" *-- "*" IDWithType : contains | ||
@enduml | ||
``` | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
title: 参考架构 | ||
date: 2024-02-01 | ||
--- | ||
|
||
# 参考架构 | ||
|
||
参考架构(Architecture Reference,下称 Arch Ref)是[推导器](./deducer.zh-CN.md)的产出,体现了应用程序映射到云上的架构,包括应用需要创建的云 BaaS 资源实例、资源实例的事件处理函数,以及资源实例之间的关系。 | ||
|
||
用户可以从 Arch Ref 中了解应用程序的架构,并确认架构是否符合预期。Pluto 会根据 Arch Ref 的内容,自动创建云上 BaaS、FaaS 资源实例,并最小化权限配置。 | ||
|
||
## 构成 | ||
|
||
Arch Ref 包含资源实例、计算闭包、资源关系三个部分,下图为 Arch Ref 的构成: | ||
|
||
![The composition of Arch Ref](../../../public/assets/arch-ref-composition.png) | ||
|
||
### 资源实例 | ||
|
||
资源实例(Resource Instance)是应用程序需要创建的云资源实例,包括资源实例的 ID、类型、名称、参数等信息。 | ||
|
||
_目前,这里的名称与 ID 可能与运行时生成的 ID 不相符,因为,ID 同样根据资源名生成,在推导阶段,资源名称对应资源对象的变量名,而运行时资源对象的名字则根据用户给定的参数确定,参数与变量名可能不同,导致推导阶段的 ID 与运行时的 ID 不同。例如:`router = new Router("name")`,在生成的 Arch Ref 中,名称为 router,在运行时,资源名称将是 name。_ | ||
|
||
### 计算闭包 | ||
|
||
计算闭包(Compute Closure)通常是资源实例的事件处理函数,如 Queue 的订阅者、Router 的路径处理函数等,包括闭包的 ID、路径信息。 | ||
|
||
其中,路径信息为闭包导出后所处的文件夹路径,为相对于应用程序根目录的相对路径。如果是 TypeScript 应用程序,计算闭包文件夹是一个 Node.js 模块,包含一个 `index.ts` 文件,和使用 esbuild 编译打包生成的 `index.js`,在该模块中,导出的 `default` 函数即为用户定义的事件处理函数。 | ||
|
||
### 资源关系 | ||
|
||
资源关系(Relationship)表示资源实例之间的关系,包括关系的作用方、类型、操作、参数等信息。 | ||
|
||
作用方可能是资源实例或计算闭包。如果是资源实例,其对应的关系类型应该是 `Create`,对应操作应该属于该资源类型的 [Infra API](./sdk.zh-CN.md),表示资源实例调用了某个 Infra API 创建了另一个资源实例或计算闭包。如果是计算闭包,其对应的关系类型应该是 `MethodCall` 或 `PropertyAccess`,表示在该计算闭包中调用了某个资源实例的 Client API 方法或属性。 | ||
|
||
`Create` 关系指导 Pluto 在编译时创建与关联资源实例,`MethodCall` 关系指导 Pluto 在编译时给计算闭包所属的 FaaS 实例配置合理的权限,`PropertyAccess` 关系指导 Pluto 在编译时给计算闭包所属的 FaaS 实例配置合理的环境变量,使其在运行时可以访问到资源实例的属性。 | ||
|
||
<!-- | ||
```plantuml | ||
@startuml | ||
class Architecture { | ||
+resources: Resource[] | ||
+closures: Closure[] | ||
+relationships: Relationship[] | ||
+addResource(resource: Resource): void | ||
+findResource(resourceId: string): Resource | undefined | ||
+addClosure(closure: Closure): void | ||
+findClosure(closureId: string): Closure | undefined | ||
+findResourceOrClosure(entityId: string): Resource | Closure | undefined | ||
+addRelationship(relationship: Relationship): void | ||
+topoSort(): (Resource | Closure | Relationship)[] | ||
} | ||
class Resource { | ||
+id: string | ||
+name: string | ||
+type: string | ||
+parameters: Parameter[] | ||
} | ||
class Closure { | ||
+id: string | ||
+path: string | ||
} | ||
class Relationship { | ||
+from: IDWithType | ||
+to: IDWithType[] | ||
+type: "Create" | "MethodCall" | "PropertyAccess" | ||
+operation: string | ||
+parameters: Parameter[] | ||
} | ||
class Parameter { | ||
+index: string | ||
+name: string | ||
+type: "closure" | "text" | ||
+value: string | ||
} | ||
class IDWithType { | ||
+id: string | ||
+type: "closure" | "resource" | ||
} | ||
' Relationships | ||
Architecture "1" *-- "*" Resource : contains | ||
Architecture "1" *-- "*" Closure : contains | ||
Architecture "1" *-- "*" Relationship : contains | ||
Resource "1" *-- "*" Parameter : contains | ||
Relationship "1" *-- "*" Parameter : contains | ||
Relationship "1" *-- "*" IDWithType : contains | ||
@enduml | ||
``` | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.