-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kindrat
committed
Nov 15, 2015
1 parent
cb961d9
commit 6ec8056
Showing
7 changed files
with
99 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/main/java/com/github/nginate/kafka/protocol/messages/Message.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.github.nginate.kafka.protocol.messages; | ||
|
||
import com.github.nginate.kafka.protocol.types.Type; | ||
import lombok.Data; | ||
|
||
import static com.github.nginate.kafka.protocol.types.TypeName.INT8; | ||
|
||
@Data | ||
public abstract class Message { | ||
@Type(INT8) | ||
private int size; | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/github/nginate/kafka/protocol/messages/Request.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.github.nginate.kafka.protocol.messages; | ||
|
||
import com.github.nginate.kafka.protocol.types.Type; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
import static com.github.nginate.kafka.protocol.types.TypeName.INT16; | ||
import static com.github.nginate.kafka.protocol.types.TypeName.INT32; | ||
import static com.github.nginate.kafka.protocol.types.TypeName.STRING; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
public abstract class Request extends Message{ | ||
@Type(INT16) | ||
private int apiKey; | ||
@Type(INT16) | ||
private int apiVersion; | ||
@Type(INT32) | ||
private int correlationId; | ||
@Type(STRING) | ||
private String clientId; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/github/nginate/kafka/protocol/messages/Response.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.github.nginate.kafka.protocol.messages; | ||
|
||
import com.github.nginate.kafka.protocol.types.Type; | ||
import com.github.nginate.kafka.protocol.types.TypeName; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
import static com.github.nginate.kafka.protocol.types.TypeName.*; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
public abstract class Response extends Message { | ||
@Type(INT32) | ||
private int correlationId; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/github/nginate/kafka/protocol/types/Type.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.github.nginate.kafka.protocol.types; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
public @interface Type { | ||
TypeName value(); | ||
boolean repeatable() default false; | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/github/nginate/kafka/protocol/types/TypeName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.github.nginate.kafka.protocol.types; | ||
|
||
public enum TypeName { | ||
/** | ||
* Signed integer (1 byte) with the given precision (in bits) stored in big endian order. | ||
*/ | ||
INT8, | ||
/** | ||
* Signed integer (2 bytes) with the given precision (in bits) stored in big endian order. | ||
*/ | ||
INT16, | ||
/** | ||
* Signed integer (4 bytes) with the given precision (in bits) stored in big endian order. | ||
*/ | ||
INT32, | ||
/** | ||
* Signed integer (8 bytes) with the given precision (in bits) stored in big endian order. | ||
*/ | ||
INT64, | ||
/** | ||
* Consist of a signed int16 giving a length N followed by N bytes of content. A length of -1 indicates null. | ||
*/ | ||
STRING, | ||
/** | ||
* Consist of a signed int32 giving a length N followed by N bytes of content. A length of -1 indicates null. | ||
*/ | ||
BYTES | ||
} |