Code Monkey home page Code Monkey logo

cellbang / malagu Goto Github PK

View Code? Open in Web Editor NEW
684.0 21.0 59.0 75.32 MB

Malagu is a Serverless First, componentized, platform-independent progressive application framework based on TypeScript. Malagu 是基于 TypeScript 的 Serverless First、组件化、平台无关的渐进式应用框架。

Home Page: https://malagu.naily.cc

License: MIT License

JavaScript 3.57% TypeScript 96.04% HTML 0.03% Vue 0.16% CSS 0.15% SCSS 0.01% Dockerfile 0.03%
serverless serverless-framework faas bff orm microapp microservice typescript platform-independent dependency-injection

malagu's Introduction

Cellbang设计说明

产品定位

一切皆文档,应用亦文档

  • 提供各种类型文件的高效的在线协作管理能力,以提升企业文件协作和共享效率;

  • 未来可提供通过文件进行配置即能实现的低代码应用能力,即应用亦文档,这是框架设计之初便存留的适配考量;

  • 基于自研技术,实现多平台一键部署的能力,适应serverless大趋势;

  • 由于IDE的核心能力是Theia IDE内核提供的,即意味着产品不仅仅提供文件协作管理能力,还具备在线研发能力:

    • 注1:其中基于Theia扩展了插件体系(仅做演示使用,暂未开放);
    • 注2:若要提供研发能力,还需要有虚拟在线运行环境的能力(即terminal),目前暂未实现;
  • 由于考虑到vscode的生态优势,未来可能考虑将IDE核心从Theia切换过去,这样产品就天然拥有所有vscode的能力(vscode插件同时支持在线虚拟文件系统,配合虚拟terminal,将有更多的想象空间)

架构图

1662558708520

现有能力清单

功能清单

  • 支持用户登录和身份认证(默认github),同时支持oauth2登录,即具备多平台授权登录能力;

  • 可读写IDE的配置并持久化,可读写文件(包括代码)并持久化;

    • 支持多种文件预览能力,包括md/txt等文本文件、png/gif等各种图片类型、xlsx等各种表格类型、pdf文件、各种快捷文件等(由核心非插件提供);
    • 工作空间管理能力,打开/保存/另存为等(由核心非插件提供);
    • 多种文件(除了代码文件,还包括docx/xlsx等文档文件)编辑能力及扩展能力(由核心非插件提供);
    • 多文件比较能力(由核心非插件提供);
  • 现场还原能力

    • 关闭当前浏览器窗口时有未保存文件的友好提示,同时下次打开地址时,基于workspace的概念,会保留现有已打开文件状态,即若某文件未保存则不会保留其未保存内容,但是依然保留其打开状态;
    • 同时拥有自动保存能力,即自动保存配置打开后,会自动保存未保存文件;
  • 文件上传能力

    • 通过文件分片上传的技术,提供可靠稳定的大文件上传能力;
    • 可拖拽上传本地文件或目录;
  • 提供国际化能力;

  • 支持多人在线协作能力,支持多种权限分享能力

    • 可下载文件,可复制下载链接
    • 链接分享支持开启和关闭
    • 要求密码分享

非功能清单

  • 多租隔离

    • 已实现不同租户请求不同,配合平台设置【单实力单并发】即可实现不同租户的函数实例隔离;

    • 数据存储隔离当前默认配置为目录级别隔离(即不同目录数据隔离),同时支持桶隔离(即不同的租户数据在不同的oss桶里)和服务账号隔离(即不同的租户数据在不同的serverless平台账户中)的组合配置;

    • 实现多租户安全,即:

      • A租户是否登录都无法查看B租户文件数据;
      • B租户分享文件给A租户的时候,有多级安全隔离:指定链接查看,根据密码查看等
  • IDE秒开特性

    • 前端通过gzip压缩+缓存优化,优化结果如下
requests transferred resources
cellbang 142 705KB 12.4MB
github.dev 2000+ 25.1MB 66.6MB
  • 后端通过优化冷热启动效率实现:

    • 函数代码打包尽可能压缩,目前优化大小控制于2-3M内;、
    • 同租户rpc请求进行合并,实现对服务实例的节约
  • 优化资源成本

    • 前后端使用基于http协议的jsonrpc协议进行通信,提升通信效率,同时实现动态合并请求;
    • 支持多云部署,平台不锁定,一键部署多平台(自研能力)

malagu's People

Contributors

2234839 avatar bingtsingw avatar chaozwn avatar coderyqy avatar coreybin avatar dependabot[bot] avatar jerrywu1234 avatar lccf avatar linlzis avatar linxiaowu66 avatar lzy2014love avatar muxiangqiu avatar vangie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

malagu's Issues

malagu文档存在的一些问题

malagu文档存在的一些问题

一、目录需要完善

目录偏重于教程,建议对文档目录进行完善。参考方案有两个

  1. vue文档目录
  • 教程
  • API
  • 风格指南
  • 示例
  • Cookbook

2.k8s文档目录

  • 主页
  • 入门
  • 概念
  • 任务
  • 教程
  • 参考
  • 贡献

这两个都是比较成功的开源项目,具有借鉴意义。

二、欠缺 api 参考

没有api参考,有限的示例过于简单,难以灵活掌握框架各项功能。一些api的用法在教程内容中目录较深找查不便,需要整理专门的api文档供参考查找。

三、示例过于简单

示例内容更象模板项目的一个归类,没有对示例用到的模块、用法进行说明。也没有相关配置项的说明。

四、缺少针对社区开发者的指引文档

没有针对整个框架代码结构及执行流程的说明文档,新的参与者如果想要参与贡献代码要从头熟悉源码,消耗大量时间和热情。社区贡献者大多是利用零散时间,提供相应的文档让有意原贡献的人快速上手可以提升效率。

五、总结

当前需补齐的内容主要为以下两块

  1. api参考、模块参考、模块配置参考
  2. 针对开发者的指引文档

建议的文档目录

  • 介绍
  • 概念(可选,如果内容量不是很多可以并入教程中,k8s中的概念特别多,所以使用了专门的章节)
  • 教程(当前文档的主要内容)
  • 参考(包含api参考、模块参考、模块配置参考等)
  • 示例&Cookbook(示例中针对template的说明可以更细化一些,可以添加一个相对完整的blog或者cms系统开发示例)
  • 贡献指南(针对社区开发者的文档及协作指引)

框架重名命名(方便记忆和传播)

目前想到的一个名字是 Cell,单元的意思,与 Malagu 框架的组件概念有异曲同工之妙。也方便识别和记忆。npm 发布的 package 名字可以使用 celljs,例如 @celljs/core 等等。

【文档完善】补充一个多环境隔离原理图

背景:未来保证项目的质量,一般会有多套运行环境,一般三套:测试、预发和线上。测试环境主要给开发人员测试验证用的,数据库一般是测试数据库;预发环境是一个非常接近线上的一个环境,预发验证没有问题后,就可以发布到线上环境了。

Malagu 框架通过组件属性的覆盖和运行模式,以及对 el 表达式支持,能够很容易做到多环境的隔离部署。

配置文件动态更新

场景

开发过程中一些针对业务的配置经常需要修改调试,当前配置文件在服务启动后无法更新,需要手动重启。

方案参考

  • 1.为配置模块添加hook,可以在代码中动态修改配置,通过代码的热更实现配置更新。开发时将需要频繁调整的配置集成在代码中,发布前迁移到yml文件中。
  • 2.侦测yml文件的更新,利用webpack的hmr动态更新配置。
  • 3.开发模式侦测到yml文件变更后自动重启当前服务。

说明:方案1实现相对简单,可满足场景需求。方案2体验好,实现复杂。方案3体验差。

vue 模版, 无法部署到阿里云, 安装 fc-adapter 和 fc-plugin, 但 cli程序 却 非要向 腾讯云部署..

image

==========================================
都是 malagu init vue-app , 没动过什么, 只是添加了 fc-adapter 和 fc-plugin.

这是 package

{
  "name": "vue-app",
  "keywords": [
    "malagu-component"
  ],
  "version": "0.0.0",
  "license": "MIT",
  "files": [
    "lib",
    "src"
  ],
  "dependencies": {
    "@malagu/cli-service": "^2.10.2",
    "@malagu/core": "latest",
    "@malagu/fc-adapter": "^2.10.2",
    "@malagu/rpc": "latest",
    "@malagu/serve-static": "latest",
    "@malagu/vue": "latest",
    "vue": "^3.0.11",
    "vue-router": "^4.0.8"
  },
  "devDependencies": {
    "@malagu/cli": "latest",
    "@malagu/fc-plugin": "^2.10.2"
  },
  "scripts": {
    "clean": "rimraf lib dist .malagu",
    "build": "malagu build",
    "start": "malagu serve",
    "deploy": "malagu deploy -m test",
    "deploy:test": "malagu deploy -m test",
    "deploy:pre": "malagu deploy -m pre",
    "deploy:prod": "malagu deploy -m prod"
  }
}

==========
这是命令行


cuiluming@RaisdeAir vue-app % npm run clean

> [email protected] clean /Users/cuiluming/Nextcloud/dev_chaoway/js/vue-app
> rimraf lib dist .malagu

cuiluming@RaisdeAir vue-app % yarn run deploy
yarn run v1.22.17
warning ../package.json: No license field
$ malagu deploy -m test

                   ___
 /'\_/`\          /\_ \
/\      \     __  \//\ \      __       __   __  __
\ \ \__\ \  /'__`\  \ \ \   /'__`\   /'_ `\/\ \/\ \
 \ \ \_/\ \/\ \L\.\_ \_\ \_/\ \L\.\_/\ \L\ \ \ \_\ \
  \ \_\\ \_\ \__/.\_\/\____\ \__/.\_\ \____ \ \____/
   \/_/ \/_/\/__/\/_/\/____/\/__/\/_/\/___L\ \/___/
                                       /\____/
                   @malagu/[email protected]  \_/__/

╭──────────────────────────────────────────────────╮
│      Serverless First Development Framework      │
│                 Runtime<malagu>                  │
╰──────────────────────────────────────────────────╯

🏔   malagu stage - test
🏷   malagu mode - remote
🏷   malagu mode - test
🏷   malagu mode - auto
🏷   malagu mode - scf-adapter
🏷   malagu mode - scf
🎯  malagu target - backend
🎯  malagu target - frontend
🧱  malagu component - @malagu/[email protected]
🧱  malagu component - @malagu/[email protected]
🧱  malagu component - @malagu/[email protected]
🧱  malagu component - @malagu/[email protected]
🧱  malagu component - @malagu/[email protected]
🧱  malagu component - @malagu/[email protected]
🧱  malagu component - @malagu/cli-service@^2.10.2
🧱  malagu component - @malagu/fc-adapter@^2.10.2
🧱  malagu component - @malagu/rpc@latest
🧱  malagu component - @malagu/serve-static@latest
🧱  malagu component - @malagu/vue@latest
🧱  malagu component - @malagu/[email protected]
🧱  malagu component - @malagu/[email protected]
🧱  malagu component - @malagu/[email protected]
🧱  malagu component - @malagu/fc-plugin@^2.10.2
🧱  malagu component - [email protected]
backend build [====================] 98% (3.3 seconds) DONE  Compiled successfully in 3316ms                                                          11:55:27

 I  The backend code output to /Users/cuiluming/Nextcloud/dev_chaoway/js/vue-app/.malagu/dist/backend 🎉

Build completed in 3.533s

frontend build [==================  ] 92% (6.4 seconds) DONE  Compiled successfully in 6387ms                                                          11:55:34

 I  The frontend code output to /Users/cuiluming/Nextcloud/dev_chaoway/js/vue-app/.malagu/dist/frontend 🎉

frontend build [====================] 99% (6.5 seconds) DONE  Compiled successfully in 6387ms                                                          11:55:34

 I  The frontend code output to /Users/cuiluming/Nextcloud/dev_chaoway/js/vue-app/.malagu/dist/frontend 🎉

 DONE  Compiled successfully in 6387ms                                                          11:55:34

 I  The frontend code output to /Users/cuiluming/Nextcloud/dev_chaoway/js/vue-app/.malagu/dist/frontend 🎉

frontend build [====================] 99% (6.6 seconds) DONE  Compiled successfully in 6387ms                                                          11:55:34

 I  The frontend code output to /Users/cuiluming/Nextcloud/dev_chaoway/js/vue-app/.malagu/dist/frontend 🎉

Build completed in 6.64s


Deploying vue-app to the cn-hangzhou region of alibaba cloud...
- Profile: 
    - AccountId: 1236284087205882
    - Region: cn-hangzhou
- SCF:
TencentCloudSDKHttpException [Error]: The SecretId is not found, please ensure that your SecretId is correct.
    at Client.parseResponse (/Users/cuiluming/.malagu/runtimes/2.10.2/default/node_modules/tencentcloud-sdk-nodejs/tencentcloud/common/abstract_client.js:134:33)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at Client.request (/Users/cuiluming/.malagu/runtimes/2.10.2/default/node_modules/tencentcloud-sdk-nodejs/tencentcloud/common/abstract_client.js:65:28)
    at getNamespace (/Users/cuiluming/.malagu/runtimes/2.10.2/default/node_modules/@malagu/scf-plugin/src/hooks/utils.ts:209:36)
    at createOrUpdateNamespace (/Users/cuiluming/.malagu/runtimes/2.10.2/default/node_modules/@malagu/scf-plugin/src/hooks/deploy.ts:130:27)
    at Object.exports.default (/Users/cuiluming/.malagu/runtimes/2.10.2/default/node_modules/@malagu/scf-plugin/src/hooks/deploy.ts:40:5)
    at HookExecutor.doRequire (/Users/cuiluming/Nextcloud/dev_chaoway/js/vue-app/node_modules/@malagu/cli-common/src/hook/hook-executor.ts:70:24)
    at HookExecutor.doExecuteHooks (/Users/cuiluming/Nextcloud/dev_chaoway/js/vue-app/node_modules/@malagu/cli-common/src/hook/hook-executor.ts:111:33)
    at exports.default (/Users/cuiluming/Nextcloud/dev_chaoway/js/vue-app/node_modules/@malagu/cli-service/src/deploy/deploy.ts:33:9) {
  requestId: '4258a483-31f4-47d1-ac1b-d381eead25a8',
  code: 'AuthFailure.SecretIdNotFound'
}
error Command failed with exit code 255.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

支持任务调度和消息队列

  1. 支持任务调度,设计可以参考 spring 的 @schedule,要求传统任务调度和 Serverless 时间触发器两者之间无缝切换。
  2. 支持消息队列,设计可以参考 spring 的 @JmsListener,要求传统任务调度和 Serverless 消息触发器两者之间无缝切换。

malagu cli 目前需要改进的点

  1. 对于命令 malagu -v, malagu -h 也需要 load cli context,需要等一点时间才能看到结果
  2. 对于不支持的框架使用 malagu deploy 命令,提示Unknown command deploy, 可以增加 malagu support list,malagu support 查看malagu 支持的框架和检测当前项目是否支持 malagu 部署
  3. 对于部署在 scf web 函数的用户, 要提醒或者文档显眼说明注意点。
  • 只能监听 9000 固定端口和地址 0.0.0.0
  • 只有 /tmp 目录可读可写, 读写其他目录文件不没有权限
  1. 增加命令 malagu deploy -c 或者 malagu deploy -config 指定部署配置,可以是json 文件和 js 文件(这两种前端项目比较常用),配置项可以有 部署平台, 部署模式, 自定义支持框架,添加环境变量 等。

TypeError: Cannot read properties of undefined (reading 'intercept')

当malagu init项目后,运行malagu serve就出现这个情况
frontend build [ ] 0% (0.0 seconds)TypeError: Cannot read properties of undefined (reading 'intercept')
at /Users/vincent_pun/Desktop/test/sample-app/node_modules/webpack/lib/ProgressPlugin.js:242:30
at Array.forEach ()
at /Users/vincent_pun/Desktop/test/sample-app/node_modules/webpack/lib/ProgressPlugin.js:239:24
at Hook.eval (eval at create (/Users/vincent_pun/Desktop/test/sample-app/node_modules/tapable/lib/HookCodeFactory.js:19:10), :104:1)
at Hook.CALL_DELEGATE [as _call] (/Users/vincent_pun/Desktop/test/sample-app/node_modules/tapable/lib/Hook.js:14:14)
at Compiler.newCompilation (/Users/vincent_pun/Desktop/test/sample-app/node_modules/@malagu/cli-service/node_modules/webpack/lib/Compiler.js:1055:26)
at /Users/vincent_pun/Desktop/test/sample-app/node_modules/@malagu/cli-service/node_modules/webpack/lib/Compiler.js:1099:29
at Hook.eval [as callAsync] (eval at create (/Users/vincent_pun/Desktop/test/sample-app/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/vincent_pun/Desktop/test/sample-app/node_modules/tapable/lib/Hook.js:18:14)
at Compiler.compile (/Users/vincent_pun/Desktop/test/sample-app/node_modules/@malagu/cli-service/node_modules/webpack/lib/Compiler.js:1094:28)
λ ~/Desktop/test/sample-app/ npm install -g @malagu/cli

阿里云自定义服务名,函数名失败

我按照 自定义部署规则 配置了 malagu.yml

malagu:
  faas-adapter:
    service:
      name: my
    function:
      name: myfun1

生成dist中的malagu.backend.yml文件如下

malagu:
  name: Malagu Framework
  hostDomId: malagu-root
  annotation:
    Component:
      proxy: false
  aop:
    enabled: true
  logger:
    level: info
  tenant:
    enabled: false
  session:
    autoCommit: true
    maxAge: 86400000
    sessionIdKey: malagu:sessionId
    sessionKey: malagu:session
  server:
    path: /2016-08-15/proxy/malagu.test/malagu/
    port: 3000
    endpoint: https://{aid}.cn-shanghai.fc.aliyuncs.com
    _domain: http://
  trace:
    requestField: X-Malagu-Trace-ID
    responseField: X-Malagu-Trace-ID
  web:
    route:
      cacheSize: 500
    validationPipeOptions:
      detailedOutputDisabled: false
      transformEnabled: true
  client:
    config:
      withCredentials: true
      headers:
        X-Requested-With: XMLHttpRequest
  mvc:
    path: /*
    defaultViewName: json
    baseFileDir: assets
  mustache:
    cache: false
    baseViewDir: assets/views
  cloud:
    name: alibaba
    faas:
      function:
        name: malagu
        handler: backend/index.handler
        codeUri: {}
        memorySize: 512
        timeout: 15
        serviceName: malagu
        instanceConcurrency: 10
        runtime: custom
        bootstrap: node backend/index.js
      alias:
        name: test
        serviceName: malagu
      secure: true
      internal: false
      timeout: 600000
      service:
        name: malagu
      trigger:
        name: malagu-test
        qualifier: test
        functionName: malagu
        serviceName: malagu
        triggerType: http
        triggerConfig:
          authType: anonymous
          methods:
            - GET
            - POST
            - PUT
            - DELETE
            - HEAD
            - PATCH
      customDomain:
        protocol: HTTP
        certConfig:
          privateKey: ssl/domain.key
          certificate: ssl/domain.pem
        routeConfig:
          routes:
            - path: /*
              serviceName: malagu
              qualifier: test
              functionName: malagu
      account:
        id: {aid}
      region: cn-shanghai
    profilePath: alibaba/profile.yml
    regions:
      - cn-qingdao
      - cn-beijing
      - cn-zhangjiakou
      - cn-hangzhou
      - cn-shanghai
      - cn-shenzhen
      - cn-huhehaote
      - cn-hongkong
      - ap-southeast-1
      - ap-southeast-2
      - ap-northeast-1
      - us-west-1
      - us-east-1
      - eu-central-1
      - ap-south-1
  faas-adapter:
    service:
      name: my
    function:
      name: myfun1
  cookies:
    keys:
      - abcdef
propsHooks: []
stage: test
targets:
  - backend
mode:
  - remote
  - test

阿里云fc仍然是创建 服务名 malagu 函数名 malagu 的函数 .

期望runtime可按需安装

问题描述:
当前执行malagu cli命令时会默认安装runtime中sfc-adapter、cil-service、sfc-plugin三个组件。

期望:
通指定参数控制是否自动安装runtime

hello

I will continue to focus on this framework

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.