tailor+ skipper 实现micro-frontends 简单试用
tailor 在Mosaic 框架中扮演fragment 模版layout的处理,后端fragment可以用任何服务编写
tailor 主要就是进行layout的处理。tailor的是类似facebook bigpipe的实现,功能
挺强大的。
说明:测试使用docker-compose 运行
环境准备
- docker-compose 文件
version: "3"
services:
skipper:
image: dalongrong/skipper:latest
ports:
- "9090:9090"
- "9911:9911"
volumes:
- "./router.eskip:/router.eskip"
command: skipper -enable-ratelimits -enable-prometheus-metrics -routes-file /router.eskip
web:
build:
context: ./
dockerfile: Dockerfile
ports:
- "8080:8080"
fragment-a:
build:
context: ./
dockerfile: Dockerfile-fragment-a
ports:
- "8081:8081"
- web dockerfile
web 服务实际上是入口服务,为了简单,使用了docker 运行,实际上就是一个node 项目,使用tailor 进行layout处理
FROM node:9
WORKDIR /app
COPY index.js /app/index.js
COPY templates /app/templates
COPY package.json /app/package.json
RUN yarn
CMD [ "yarn","start"]
index.js 是入口
'use strict';
const http = require('http');
const Tailor = require('node-tailor');
const tailor = new Tailor({
templatesPath: './templates'
});
// Root Server
http
.createServer((req, res) => {
tailor.requestHandler(req, res);
})
.listen(8080, function() {
console.log('Tailor server listening on port 8080');
});
模版定义
templates 目录下,注意需要一个index.html 的文件
<!-- Tailor needs an index.html -->
<h1>dalong demo</h1>
// 此处使用skipper 的router 之后的地址
<fragment primary id="fragment-1" src="http://skipper:9090/fragment-a"></fragment>
- fragment dockerfile
fragment 是具体的代码片段的代码,这个比较简单,就是一个html 页面的输出
FROM node:9
WORKDIR /app
COPY fragment-a/* /app/
EXPOSE 8081
CMD [ "yarn","start" ]
fragment-a/index.js
const http = require('http');
http
.createServer((req, res) => {
res.writeHead(200, {
'Content-Type': 'text/html'
});
res.end('<div>Fragment 1</div>');
})
.listen(8081, function() {
console.log('Fragment Server listening on port 8081');
});
- skipper router 配置
主要是对于路由的添加,同时添加了一些filter 支持gzip 以及cors
root: Path("/") ->setPath("/index")->compress("text/html")-> corsOrigin()
->setResponseHeader("TOKEN","dalongdemo") ->"http://web:8080";
fragment_a: Path("/fragment-a") ->compress("text/html")-> corsOrigin()
->"http://fragment-a:8081";
启动&&测试
- 启动
docker-compose up -d
- 效果
访问http://localhost:9090 可以查看效果,或者http://localhost:8080/index 访问没有使用skipper 的入口

说明
测试代码很简单,实际可以支持好多强大的功能,具体的可以参考tailor 的examples 目录
参考资料
https://www.mosaic9.org/
https://github.com/zalando/tailor
https://github.com/rongfengliang/tailor-skipper-docker-compose
tailor+ skipper 实现micro-frontends 简单试用的更多相关文章
- Micro Frontends
Micro Frontends - extending the microservice idea to frontend development https://micro-frontends.or ...
- Micro Frontends 微前端
Micro Frontends https://martinfowler.com/articles/micro-frontends.html Integration approaches Server ...
- Micro Frontends & microservices
Micro Frontends & microservices https://micro-frontends.org/ https://github.com/neuland/micro-fr ...
- skipper http router 简单试用
说明: 使用源码编译,注意需要FQ,以及golang版本的问题,新版使用的是go mod 进行依赖管理 环境准备 clone 代码 git clone https://github.com/zalan ...
- jQuery无刷新上传之uploadify简单试用
先简单的侃两句:貌似已经有两个月的时间没有写过文章了,不过仍会像以前那样每天至少有一至两个小时是泡在园子里看各位大神的文章.前些天在研究“ajax无刷新上传”方面的一些插件,用SWFUpload实现了 ...
- Micro:Bit手柄试用之一MagicPad (解决蓝牙与gamePad包共存)
前言 原创文章,转载引用务必注明链接.由于本人初次接触Micro:Bit,水平有限,如有疏漏,欢迎指正. Micro:Bit真好玩! DFRobot的论坛相关资料算是国内比较丰富的了,个人感觉MB比A ...
- cloudevents js sdk 简单试用
cloudevents 目前官方提供了不同语言的sdk,以下是js 的简单学习试用,从目前来说更新不是很好 clone 代码 git clone https://github.com/cloudeve ...
- podium micro-frontends 简单试用
以下是一个简单的podium 试用,包含了layout 以及podlets,使用docker 运行 podium 主要包含了两大部分 podlets 片段服务 layouts 片段组合服务 环境准备 ...
- Visual Studio Code 的简单试用体验
首先对Visual Studio Code做一个大概的介绍.首先明确一下,这个Visual Studio Code(以下简称 vscode)是一个带GUI的代码编辑器,也就是只能完成简单的代码编辑功能 ...
随机推荐
- confirm消息对话框
function rec(){ var mymessage= confirm("你是女孩?") ; if(mymessage==true) { document.write(&qu ...
- 第三节 java 函数的封装方法 以及 访问封装内容
从我们的选择排序和冒泡排序里我们可以看到有很多相同的代码, 我们 可以把这些相同的代码提取出来封装为方法:比如我们的判 断交换和遍历输出: 抽取1: public static void PanDua ...
- DevExpress v18.1新版亮点——Reporting篇(二)
用户界面套包DevExpress v18.1日前终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExpress Reporting v18.1 的新功能,快来下载试用新版本 ...
- Mysql使用information.shema.tables查询数据库表大小
简介: information_schema数据库中的表都是只读的,不能进行更新.删除和插入等操作,也不能加触发器,因为它们实际只是一个视图,不是基本表,没有关联的文件. 元数据描述数据的数据,用于描 ...
- quartz自定义线程数
1.加载包 2.添加quartz.propertes 3.编写自己的任务类 4.添加自动任务配置 5.通过 quartzProperties 配置连接池 1.加载包 <dependency> ...
- Codeforces Round #212 (Div. 2) C. Insertion Sort
C. Insertion Sort Petya is a beginner programmer. He has already mastered the basics of the C++ lang ...
- input-event-codes.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Input event codes * * *** IMPORT ...
- CentOS 7部署Java+Mysql步骤
1.工具 putty0.7:用于远程控制服务器 winSCP5.13: ftp工具,用于向远程服务器传送文件 2.安装jdk: yum -y install java-1.8.0-openjdk ja ...
- 使用OpenBTS基站测试物联网模块安全性
0×00 引子 近年来,随着云计算.物联网技术的快速发展,物联网的理念和相关技术产品已经广泛渗透到社会经济民生的各个领域,越来越多的穿戴设备.家用电器通过蓝牙.Wi-Fi.Li-Fi.z-wave.L ...
- Java学习笔记28(IO字节流)
IO定义: 写:Output操作:将内存上的数据持久化 到设备上,这个动作称为输出: 读:Input操作:把硬盘上的东西读取到内存,这个动作称为输入: 这两种操作称为IO流 ...