breeze

serializer for multi language.

License

License

GroupId

GroupId

com.weibo
ArtifactId

ArtifactId

breeze
Last Version

Last Version

0.1.4
Release Date

Release Date

Type

Type

pom
Description

Description

breeze
serializer for multi language.
Project URL

Project URL

https://github.com/weibreeze/breeze.git
Source Code Management

Source Code Management

https://github.com/weibreeze/breeze

Download breeze

Filename Size
breeze-0.1.4.pom 5 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/com.weibo/breeze/ -->
<dependency>
    <groupId>com.weibo</groupId>
    <artifactId>breeze</artifactId>
    <version>0.1.4</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.weibo/breeze/
implementation 'com.weibo:breeze:0.1.4'
// https://jarcasting.com/artifacts/com.weibo/breeze/
implementation ("com.weibo:breeze:0.1.4")
'com.weibo:breeze:pom:0.1.4'
<dependency org="com.weibo" name="breeze" rev="0.1.4">
  <artifact name="breeze" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.weibo', module='breeze', version='0.1.4')
)
libraryDependencies += "com.weibo" % "breeze" % "0.1.4"
[com.weibo/breeze "0.1.4"]

Dependencies

compile (2)

Group / Artifact Type Version
org.slf4j : slf4j-api Optional jar 1.7.24
org.slf4j : slf4j-simple Optional jar 1.7.24

test (1)

Group / Artifact Type Version
junit : junit jar 4.13.1

Project Modules

  • breeze-core
  • breeze-autoscan
  • breeze-protobuf
  • breeze-spring
  • breeze-maven-plugin

Breeze

License Maven Central Build Status

概述

Breeze是一个跨语言序列化协议与服务描述schema,与protobuf类似,但更加易用并且提供对旧对象的兼容能力。

功能

  • 支持多语言。提供Java, Golang, PHP, CPP等版本实现。
  • 提供Breeze Generator可以自动生成多语言代码。
  • 高性能、序列化结果更小。
  • 简单易用。
  • 对已经存在的bean对象提供更好的兼容性,可以直接进行序列化,不需要替换为breeze自动生成的对象。

快速入门

  1. 添加依赖
        <dependency>
            <groupId>com.weibo</groupId>
            <artifactId>breeze-core</artifactId>
            <version>RELEASE</version>
        </dependency>
  1. 基础类型编解码
        //编码
        BreezeBuffer buffer = new BreezeBuffer(256);// 设置合适的buffer大小
        String str = "just test";
        BreezeWriter.writeString(buffer, str);
        buffer.flip();
        byte[] result = buffer.getBytes();

        //解码
        BreezeBuffer newBuffer = new BreezeBuffer(result);
        String newStr = BreezeReader.readString(newBuffer);
        System.out.println(newStr);
  1. 集合类型编解码
        //编码
        BreezeBuffer buffer = new BreezeBuffer(256);// 设置合适的buffer大小
        List<String> list = new ArrayList<>();
        list.add("s1");
        list.add("s2");
        BreezeWriter.writeCollection(buffer, list);
        buffer.flip();
        byte[] result = buffer.getBytes();

        //解码
        BreezeBuffer newBuffer = new BreezeBuffer(result);
        List<String> newList = new ArrayList<>();
        BreezeReader.readCollection(newBuffer, newList, String.class);
        System.out.println(newList.get(0));
  1. 类型嵌套编解码
        //编码
        BreezeBuffer buffer = new BreezeBuffer(256);// 设置合适的buffer大小
        List<String> list = new ArrayList<>();
        list.add("s1");
        list.add("s2");
        Map<Integer, List<String>> map = new HashMap<>();
        map.put(12, list);
        BreezeWriter.writeMap(buffer, map);
        buffer.flip();
        byte[] result = buffer.getBytes();

        //解码
        BreezeBuffer newBuffer = new BreezeBuffer(result);
        Map<Integer, List<String>> newMap = new HashMap<>();
        BreezeReader.readMap(newBuffer, newMap, String.class, List.class);// 泛型类型建议使用ParameterizedType作为参数。
        System.out.println(newMap.get(12).get(0));
  1. Breeze Message编解码
        //编码
        BreezeBuffer buffer = new BreezeBuffer(256);// 设置合适的buffer大小
        TestMsg msg = BreezeRWTest.getDefaultTestMsg(); // BreezeRWTest at https://github.com/weibreeze/breeze/blob/master/breeze-core/src/test/java/com/weibo/breeze/BreezeRWTest.java
        BreezeWriter.writeObject(buffer, msg);
        buffer.flip();
        byte[] result = buffer.getBytes();

        //解码
        BreezeBuffer newBuffer = new BreezeBuffer(result);
        TestMsg newMsg = BreezeReader.readObject(newBuffer, TestMsg.class);
        System.out.println(newMsg.getMyString());
  1. Object编解码
        //编码
        BreezeBuffer buffer = new BreezeBuffer(256);// 设置合适的buffer大小
        TestObj obj = BreezeRWTest.getDefaultTestObj();
        BreezeWriter.writeObject(buffer, obj);
        buffer.flip();
        byte[] result = buffer.getBytes();

        //解码
        BreezeBuffer newBuffer = new BreezeBuffer(result);
        TestObj newObj = BreezeReader.readObject(newBuffer, TestObj.class);
        System.out.println(newObj.getString());

使用Breeze Schema生成Message类

参见breeze-generator

文档

参见Wiki

com.weibo

WeiBreeze

Versions

Version
0.1.4
0.1.3
0.1.1
0.1.0
0.0.3
0.0.2
0.0.1