Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Schizo分进程自动化框架
Search
L.J.
November 28, 2018
Programming
1
120
Schizo分进程自动化框架
一个极其易用的响应式分进程模块框架 (基于 RxJava
L.J.
November 28, 2018
Tweet
Share
Other Decks in Programming
See All in Programming
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
200
Fluid Templating in TYPO3 14
s2b
0
130
CSC307 Lecture 08
javiergs
PRO
0
670
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
180
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
660
Package Management Learnings from Homebrew
mikemcquaid
0
230
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
React Native × React Router v7 API通信の共通化で考えるべきこと
suguruooki
0
100
Claude Codeと2つの巻き戻し戦略 / Two Rewind Strategies with Claude Code
fruitriin
0
140
ぼくの開発環境2026
yuzneri
0
240
Gemini for developers
meteatamel
0
100
CSC307 Lecture 10
javiergs
PRO
1
660
Featured
See All Featured
Designing Powerful Visuals for Engaging Learning
tmiket
0
240
Building the Perfect Custom Keyboard
takai
2
690
Designing for Timeless Needs
cassininazir
0
130
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
Prompt Engineering for Job Search
mfonobong
0
160
A Modern Web Designer's Workflow
chriscoyier
698
190k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
65
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
210
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
37k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.1k
Code Review Best Practice
trishagee
74
20k
The untapped power of vector embeddings
frankvandijk
1
1.6k
Transcript
分进程自动化框架 Schizo liujun@meizu 2018年 11月 28日 / 深分
Schizo 分进程框架 • 分进程(IPC • 模块化与组件化 • 响应式(RxJava • 架构与自动化
• 使用
IPC Android IPC Mechanism By Jim Huang, 0xlab, March 19,
2012 / 南台科大
模块化与组件化 • 模块化与组件化 • 模块组件化 • 进程与模块 • 统一接口规则
模块化与组件化 类别 目的 特点 接口 成果 架构定位 组件 重用、解耦 高重用、松耦合
无统一接口 基础库、基础组 件 纵向分层 模块 隔离、封装 高内聚、松耦合 统一接口 业务框架、业务 模块 横向分块 • 组件:RxJava2,Retrofit,Glide,库 • 模块:账户模块,下载模块,美图业务模块,定位服务
模块组件化 Retrofit 组件 Glide 组件 RxJava2 组件 账户模块 下载模块 美图业务模块
定位服务
模块组件化 artifactory Jcenter() 模块与组件 (gradle 发布)
进程与模块 ProcessA 网络服务 账户服务 ProcessB 下载服务
统一接口规则 • Single<T>:用于一次请求一次返回 • 调用一个普通的接口,客户端向服务端查询一个数据 • Observable<T>:用于一次请求,分次返回 • 例如监听下载进度、监听网络变化 •
统一 AIDL 传输格式与协议:Json String • 根据实现自动生成调用接口 @Api("person") Person getPerson(String name) { return new Person("Hello", "Schizo"); } 自动生成 public static Single<Person> person(String name) {…}
RxJava Reactive Extensions Programming by 刘俊, Aug 4, 2015 /
魅族
普通 IPC 接口调用 普通 IPC 调用 服务 Api 参数 返回
响应式(RxJava 响应式调用 服务 Api 参数 返回 异常 异步 Functional
架构与自动化 • 数据流 • 接口隔离 • 接口设计 • 自动生成 •
持续集成
数据流 POJO(Input) Json parcel Json POJO(Input) Converter Converter AIDL AIDL
RxBinder parcel 处理业务 POJO(Output) Json Converter parcel AIDL AIDL RxBinder parcel Json POJO(Output) Converter
接口隔离 阅读别人写的代码
接口隔离 使用别人的代码
接口隔离 Bus / EventBus 理想 实际
接口隔离 原则 • 接口与实现分离 • 根据实现自动生成接口文件 • 实现分割到模块颗粒大小 • 维持代码边界
• 模块独立 • Artifactory 远程仓库依赖 • 禁止外部模块耦合 • 不得互相依赖
接口设计 Schizo Annotation 响应式调用 服务 Api 参数 返回 异常 异步
Functional Action Annotation Api Annotaion Schizo Annotation Schizo Processor Rxjava
自动生成 咖啡店实现(服务端
自动生成 咖啡店实现(服务端, 分进程 <service android:name=".service.StartBucks" android:enabled="true" android:process=":producers"> <intent-filter> <action android:name="io.jween.service.starbucks"
/> </intent-filter> </service>
自动生成 SchizoProcessor 根据 StartBucks 自动生成 StarBucksApi @Action("io.jween.service.starbucks") public class StartBucks
extends SchizoService { @Api("getCoffee") Coffee makeCoffee(String name) throws Exception{ … } } 自动生成 Processor
自动生成 咖啡店接口(客户端, 自动生成, 使用者无法更改 public final class StartBucksApi { private
static final String ACTION = "io.jween.service.starbucks"; public static void attach(Context context) { ComponentManager.attach(context, ACTION); } public static void detach() { ComponentManager.detach(ACTION); } public static Single<Coffee> getCoffee(String name) { TypeToken<Coffee> typeToken = new TypeToken<Coffee>(){}; Type type = typeToken.getType(); return ComponentManager.get(ACTION).process("getCoffee", name, type); } }
自动生成 咖啡店接口(使用 Disposable disposable = StartBucksApi.getCoffee("Cappuccino") .observeOn(AndroidSchedulers.mainThread()) .subscribe( new Consumer<Coffee>()
{ @Override public void accept(Coffee coffee) throws Exception { Log.v("StarBucks", "Purchased a cup of " + coffee.getName() + "from" + coffee.getProducer()); } }, new Consumer<Throwable>() { @Override public void accept(Throwable throwable) throws Exception { SchizoException exception = SchizoExceptions.from(throwable); int errorCode = exception.getCode(); String errorMsg = exception.getMessage(); // handle your exceptions } });
自动生成 Observable @Api("observeConnection") Observable<Boolean> observeConnection() { return networkMonitor.observeConnection(); } public
static Observable<Boolean> observeConnection() { TypeToken<Boolean> typeToken = new TypeToken<Boolean>(){}; Type type = typeToken.getType(); return ComponentManager.get(ACTION) .processObserver("observeConnection", null, type); } CoreService CoreServiceApi 自 动 生 成
持续集成 实际项目举例 • pcore: 核心模块,单独迭代,发布到内部 Artifactory • apply plugin: 'com.meizu.publisher’
• meizu.libGroup=com.meizu.flyme.gamecenter • meizu.libId=core • meizu.libVersion=1.2.0 • meizu.distribute=jar,aar • pappmanager: App 下载管理模块,单独迭代,依赖 pcore • implementation 'com.meizu.flyme.gamecenter:core:1.2.0' pcore pappmanager App artifactory
持续集成 • 独立开发,每个模块独立研发 • 依赖处理,gradle 处理依赖关系 • 复用模块,别的 App 也能复用我们发布的模块(考虑边界
• 潜规则: • p 开头命名的模块表示使用了分进程 • 其余的为正常 Android Library Module • 无论分进程模块还是普通模块,通信都是一样的 • Analyze Dependencies 可以分析模块依赖关系(Gradle 红利 • ./gradlew pcore:dependencies
持续集成 jenkins artifactory 内部模块/ 敏感组件 gerrit 模块使用 gitlab CI 工具
bintray 独立模块/ 公共组件
Demo 使用