Skip to content

Commit

Permalink
doc[readme]: add links.
Browse files Browse the repository at this point in the history
Add links to features.
  • Loading branch information
Deng-Ran committed Jun 15, 2021
1 parent d0633aa commit 43d7b00
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ FastProto is a protocolized binary serialization & deserialization tool written
customize binary format through annotations. It solves the problem of cross-language and cross-platform data sharing
of Java in a new form, especially suitable for the field of Internet of Things(IoT).

[formula]: [https://github.com/indunet/fastproto/wiki/Conversion-Formula]
[kafka]: [https://github.com/indunet/fastproto/wiki/Work-with-Kafka]

## *Features*

* Binary serialization & deserialization
* Control the serialization process through annotations
* Support all Java primitive data types and their wrapper classes
* Support [decoding formula & encoding formula][formula]
* Customize binary format through annotations
* Support unsigned data types such as uint8, uint16, uint32 and uint64
* Custom endianness(big endian or little endian), datagram reverse addressing
* Support datagram compress and decompress(gzip, deflate)
* AutoType, automatically infer all Java primitive data types and their wrapper classes when using `@AutoType`
* Kafka serializer & deserializer
* Built-in [Kafka serializer & deserializer][kafka]

## *Under Developing*

Expand Down Expand Up @@ -119,7 +122,7 @@ public class PressureDecodeFormula implements Function<Long, Double> {
Modify the annotation and data type of the pressure field.

```
@UInteger32Type(value = 14, afterDecode = DecodeSpeedFormula.class, beforeEncode = EncodeSpeedFormula.class)
@UInteger32Type(value = 14, afterDecode = DecodeSpeedFormula.class)
double pressure;
```

Expand All @@ -135,7 +138,7 @@ public class PressureEncodeFormula implements Function<Double, Long> {
}
```

Modify the annotation and data type of the pressure field.
Modify the annotation of the pressure field.

```
@UInteger32Type(value = 14, afterDecode = PressureDecodeFormula.class, beforeEncode = PressureEncodeFormula.class)
Expand Down
28 changes: 14 additions & 14 deletions src/test/java/org/indunet/fastproto/kafka/KafkaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ public class KafkaTest {

@Test
public void testKafka() {
Properties props = new Properties();
Properties producerConfig = new Properties();
producerConfig.put("bootstrap.servers", sharedKafkaTestResource.getKafkaConnectString());
producerConfig.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
producerConfig.put("value.serializer", ProtoKafkaConfig.SERIALIZER_NAME_VALUE);
producerConfig.put(ProtoKafkaConfig.PROTOCOL_CLASS_KEY, Weather.class);
producerConfig.put(ProtoKafkaConfig.DATAGRAM_LENGTH_KEY, 26);

props.put("bootstrap.servers", sharedKafkaTestResource.getKafkaConnectString());
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", ProtoKafkaConfig.SERIALIZER_NAME_VALUE);
Properties consumerConfig = new Properties();
consumerConfig.put("bootstrap.servers", sharedKafkaTestResource.getKafkaConnectString());
consumerConfig.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
consumerConfig.put("value.deserializer", ProtoKafkaConfig.DESERIALIZER_NAME_VALUE);
consumerConfig.put("group.id", "1");
consumerConfig.put(ProtoKafkaConfig.PROTOCOL_CLASS_KEY, Weather.class);

props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
props.put("value.deserializer", ProtoKafkaConfig.DESERIALIZER_NAME_VALUE);
props.put("group.id", "1");

props.put(ProtoKafkaConfig.PROTOCOL_CLASS_KEY, Weather.class);
props.put(ProtoKafkaConfig.DATAGRAM_LENGTH_KEY, 26);

val producer = new KafkaProducer<String, Weather>(props);
val consumer = new KafkaConsumer<String, Weather>(props);
val producer = new KafkaProducer<String, Weather>(producerConfig);
Weather weather = Weather.builder()
.id(101)
.time(new Timestamp(System.currentTimeMillis()))
Expand All @@ -84,8 +84,8 @@ val record = new ProducerRecord<String, Weather>("fastproto.weather", weather);
Thread thread = new Thread(task);
thread.start();

val consumer = new KafkaConsumer<String, Weather>(consumerConfig);
consumer.subscribe(Collections.singletonList("fastproto.weather"));

ConsumerRecords<String, Weather> records = consumer.poll(Duration.ofSeconds(10));
consumer.commitSync();

Expand Down

0 comments on commit 43d7b00

Please sign in to comment.