euskadi31 / message-event-protocol
dev-master
2017-03-23 12:59 UTC
Requires
- hoa/cli: ~2.0
- hoa/compiler: ~3.0
Requires (Dev)
- kherge/box: ^2.7
This package is not auto-updated.
Last update: 2024-09-15 00:50:24 UTC
README
Message Event Protocol 是一种语言无关的可扩展机制,用于在 JSON 中序列化结构化数据。
进行中
目标支持
- PHP 5.5
- PHP 7.1 (即将推出)
- TypeScript 2
- Go
- Java (即将推出)
- Swift 3 (即将推出)
开始使用
生成 PHP5 文件
./bin/mepc -o out_dir/ -t php5 MyEvent.mep
生成 Go 文件
./bin/mepc -o out_dir/ -t go MyEvent.mep
支持的类型
字符串
布尔值
整数
浮点数
DateTime
日期
任何
Set<T>
Map<T, T>
示例
MyEvent.mep
package Acme\Event;
option java_package = "com.acme.event";
option go_extends = "no";
option php_serializer = "native";
message User {
required Integer id;
required String email;
optional String firstname;
optional String lastname;
}
message Device {
required String type;
optional String os;
optional String osVersion;
optional String brand;
optional String manufacturer;
optional String model;
optional String serial;
}
message Context {
required User user;
required Device device;
}
message Event {
required String id;
required String type;
required String action;
required Context context;
required Any payload;
required DateTime createdAt;
required DateTime sentAt;
}
message Size {
required Integer width;
required Integer height;
}
message PageViewPayload {
required String url;
required String referer;
required String title;
required Set<String> keywords;
required Map<String, String> opengraph;
required Size screen;
required Size viewport;
required String encoding;
}
许可
message-event-protocol 在 MIT 许可证下授权。