$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Schizo分进程自动化框架
Search
L.J.
November 28, 2018
Programming
1
110
Schizo分进程自动化框架
一个极其易用的响应式分进程模块框架 (基于 RxJava
L.J.
November 28, 2018
Tweet
Share
Other Decks in Programming
See All in Programming
認証・認可の基本を学ぼう後編
kouyuume
0
240
Navigating Dependency Injection with Metro
l2hyunwoo
1
120
マスタデータ問題、マイクロサービスでどう解くか
kts
0
110
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
180
公共交通オープンデータ × モバイルUX 複雑な運行情報を 『直感』に変換する技術
tinykitten
PRO
0
120
TUIライブラリつくってみた / i-just-make-TUI-library
kazto
1
400
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
850
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
120
Context is King? 〜Verifiability時代とコンテキスト設計 / Beyond "Context is King"
rkaga
10
1.3k
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
2
500
チームをチームにするEM
hitode909
0
350
宅宅自以為的浪漫:跟 AI 一起為自己辦的研討會寫一個售票系統
eddie
0
510
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Building an army of robots
kneath
306
46k
How STYLIGHT went responsive
nonsquared
100
6k
What does AI have to do with Human Rights?
axbom
PRO
0
1.9k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
16
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
46
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
115
91k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
The Cost Of JavaScript in 2023
addyosmani
55
9.4k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
69
We Are The Robots
honzajavorek
0
110
Google's AI Overviews - The New Search
badams
0
860
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 使用