com.weibo:breeze-protobuf

serializer for multi language.

License

License

Categories

Categories

Protobuf Data Data Structures
GroupId

GroupId

com.weibo
ArtifactId

ArtifactId

breeze-protobuf
Last Version

Last Version

0.1.4
Release Date

Release Date

Type

Type

jar
Description

Description

serializer for multi language.

Download breeze-protobuf

How to add to project

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

Dependencies

compile (4)

Group / Artifact Type Version
com.weibo : breeze-core jar 0.1.4
com.google.protobuf : protobuf-java jar 3.6.1
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

There are no modules declared in this project.

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.2
0.1.1
0.1.0
0.0.4
0.0.3
0.0.2
0.0.1