🦋
Butterfly 用户手册
  • Introduction
  • 一 前言
  • 二 开始
    • 安装部署
    • 五分钟体验指南
    • 单机使用手册
    • 应用规范
      • handler specs
      • middleware specs
      • xingqiao_plugin specs
      • yiqiu_program specs
  • 三 客户端功能
    • MySQL 原生协议
    • MySQL ORM
    • Redis 原生协议
      • redis_config
      • redis_tls
    • Redis ORM
    • Redis mcpack
    • Localcache
    • Kazoo
  • 四 应用(通用服务)
    • API JSON 规范
    • 异步任务 BaiChuan(百川)
    • 任务调度 RuQi(如期)
    • 任务编排 XingQiao(星桥)
    • 配置管理 WuXing(五行)
    • 运筹决策 BaiCe(百策)
  • 五 部署运维
    • 单机容器化部署
    • 监控
    • 异常排查
      • CPU Load spike every 7 hours
    • 升级
    • 安全
    • 其他
  • 六 前端
    • butterfly_template
    • butterfly_fe
    • butterfly-admin(json2web)
      • amis
      • sso
      • pangu
    • NoahV
    • PyWebIO
  • 七 潘多拉魔盒
    • 装饰器
      • localcache_decorator
      • retry_decorator
      • custom_decorator
      • command2http_decorator
    • 算法
      • 算法-分位数
      • 算法-变异系数
    • 实用工具
      • host_util
      • shell_util
      • http_util
      • time_util
      • random_util
      • concurrent
      • jsonschema
      • blinker
      • toml
      • command_util
      • config_util
      • picobox
      • 对称加密
        • des
        • aes
      • ascii_art
        • ttable
        • chart
      • business_rules
      • python-mysql-replication
      • dict_util
    • 中间件
      • middleware_status
      • middleware_whitelist
    • test_handler.py
  • 八 最佳实践
    • 分布式架构
    • Code practice
    • Log practice
    • Daemon process
  • 附录
Powered by GitBook
On this page

Introduction

Python 轻量 web 框架 butterfly

    __          __  __            ______
   / /_  __  __/ /_/ /____  _____/ __/ /_  __
  / __ \/ / / / __/ __/ _ \/ ___/ /_/ / / / /
 / /_/ / /_/ / /_/ /_/  __/ /  / __/ / /_/ /
/_.___/\__,_/\__/\__/\___/_/  /_/ /_/\__, /
                                    /____/

Butterfly(轻量化 WSGI web 应用程序框架)如同蝴蝶一样,小而美,简单可依赖。目的是让入门变得简单快捷,能够扩展到复杂的应用程序。

  • 接入 --- 【接入】函数快速适配:普通 Python 函数可快速升级为 butterfly handler

  • 模型 --- 【模型】数据库支持:自带 ORM, 支持存储数据到 MySQL,Redis,LocalCache

  • 异步 --- 【百川】任务异步处理:任一 butterfly handler 皆可消费,异步处理 MQ 中消息

  • 定时 --- 【如期】任务定时调度:设置 butterfly handler 执行时间,定期执行 handler

  • 编排 --- 【星桥】任务依赖编排:设置 butterfly handler 依赖顺序,有序编排 handler

#################################################################################################<1 接入 >##
+common func----------------------------+    +butterfly handler-----------------------------------------+
|                                       |    |     ---------------(1) 增加装饰器标识 api 类型
|                                       |    |    /            ---(2) 增加 req 参数(Request 对象)
|                                       |    |   /           /
|                                       |    |@funcattr.api /
|def hello(str_info):                   |===>|def hello(req, str_info):
|    ...                                |    |    ...
|    return "OK", {"str_info": str_info}|    |    return "OK", {"str_info": str_info}
|                                       |    |    ----------------------------------
|                                       |    |    (3) 返回 stat, [data_dict 可选 ], [handler_list 可选 ]
+---------------------------------------+    +------------------+-----------------------------+---------+
################################################################|#############################|##<2 模型 >##
                                                                |                             |
                                        +----------+------------V--------------------+        |
                                        |  Media   |             Usage               |        |
                                        +----------+---------------------------------+        |
                                        |  MySQL   | ORM,Native method               |        |
                                        +----------+---------------------------------+        |
                                        |  Redis   | ORM,Native method,Baidu RAL     |        |
                                        +----------+---------------------------------+        |
                                        |Localcache| set/get ...                     |        |
                                        +----------+---------------------------------+        |
##############################################################################################|##<3 异步 >##
                  +Redis(message queue)-----------------------------------------+             |
                  | +msg------------------------+                               |             |
                  | |'{"str_info":"helloworld"}'|                               |             |
                  | +-+-------------------------+                               |             |
                  |   |       +queue-----------------------------+              |             |
                  |   +------>|         /demo_api/hello          |<---------+   |             |
                  |    lpush  +----------------------------------+   rpop   |   |             |
                  |                               +-------------------------+-+ |             |
                  |                               |'{"str_info":"helloworld"}'| |<------------+
                  |                               +---------------------------+ |
                  +-^-------------------^---------------------------------------+
####################|###################|########################################################<4 定时 >##
                                        |
        +-----------+----------+        |
        |         ruqi         |        |
        +----------------------+        |
########################################|########################################################<5 编排 >##
                                        |
                            +taskflow---+---------------------------+
                            |                    +Task------------+ |
                            |                +---|/{app}/{handler}| |
                            |                |   +----------------+ |
                            | +Job-------+   |   +Task------------+ |
                            | |          +---+---|/{app}/{handler}| |
                            | +----------+   |   +----------------+ |
                            |                |   +Task------------+ |
                            |                +---|/{app}/{handler}| |
                            |                    +----------------+ |
                            |               xingqiao                |
                            +---------------------------------------+
Next一 前言

Last updated 11 months ago