blocklet / blocklet-specification

Blocklet Specification Documents
Apache License 2.0
1 stars 0 forks source link

[Thread] How to define blocklet interfaces #2

Closed wangshijun closed 3 years ago

wangshijun commented 4 years ago

这是个讨论的帖子,问题来源:https://github.com/blocklet/blocklet-specification/pull/1 以及 https://github.com/ArcBlock/abt-node/issues/1252

问题描述

Blocklet 如何通过 blocklet.yml 告诉 ABT Node 对外暴露哪些服务、界面等等。典型的场景,比如:

约束条件:需要允许 blocklet 暴露任何他想要暴露的接口、服务出去。

或者换句话说,我们需要把当前 meta spec 中下列字段整合:

解决方案

在 blocklet meta 中定义 interfaces 字段,把 interface 分为 UI、API、Service 三类

interfaces:
    # define UI interfaces
    - type: UI
      name: public_url
      path: /
      port: 'BLOCKLET_PORT'
    - type: UI
      name: admin_url
      path: /admin
      port: 'BLOCKLET_PORT'

    # define API interface
    - type: API
      name: graphql
      path: /api/gql
      port: 'BLOCKLET_PORT'

    - type: API
      name: websocket
      path: /api/socket
      port: 'BLOCKLET_PORT'

    - type: API
      name: graphql
      path: /api/forge
      port: 'BLOCKLET_PORT'

    # define services
    - type: SERVICE
      protocol: udp
      name: dns
      port:
            internal: 'BLOCKLET_DNS_PORT'
            external: 53
    - type: SERVICE
      name: p2p
      port:
            internal: 'BLOCKLET_P2P_PORT'
            external: 26535

interfaces 是个列表,每个条目包含如下字段:

ABT Node 的行为

通常 Blocklet 只需要在 Meta File 里面申明自己的 interface 列表,ABT Node 根据 Meta 分配必要的端口,然后通过环境变量传给 Blocklet。

而如果 Blocklet 在启动之后需要分配更多的端口,需要 ABT Node 动态提供,需要 ABT Node 暴露出去一个接口,并且该接口只能被安全的调用(可以在阶段 II 实现)。

Routing Engine 默认各 interface 用的是 80/443 端口,除非 interface 里面单独申明了 protocol

wangshijun commented 4 years ago

https://github.com/ArcBlock/abt-node/issues/1575

mave99a commented 4 years ago

We should also consider gRPC. Forge have it, and also future blocklet likely will need it.

wangshijun commented 3 years ago

https://github.com/ArcBlock/abt-node/issues/1777

wangshijun commented 3 years ago

https://github.com/ArcBlock/abt-node/issues/1252

wangshijun commented 3 years ago

https://github.com/ArcBlock/abt-node/issues/1252