Skip to content

Commit

Permalink
Merge branch 'master' of code.dianpingoa.com:arch/pigeon
Browse files Browse the repository at this point in the history
  • Loading branch information
andyyin committed Mar 9, 2017
2 parents 11cbc26 + 7cc0332 commit a138c43
Show file tree
Hide file tree
Showing 8 changed files with 4,656 additions and 2 deletions.
33 changes: 33 additions & 0 deletions entities.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
syntax = "proto3";
option java_package = "com.dianping.pigeon.remoting.common.codec.protobuf";
import "google/protobuf/any.proto";

message Pb3Request {
int32 serialize = 1; // 没有找到byte类型,用int代替
int64 seq = 2;
int32 messageType = 3;
int32 timeout = 4;
string serviceName = 5;
string methodName = 6;
repeated google.protobuf.Any parameters = 7;
int32 callType = 8;
string version = 9;
string app = 10;
map<string, string> globalValues = 11;
map<string, string> requestValues = 12;
}

message Pb3Response {
int32 serialize = 1; // 没有找到byte类型,用int代替
int64 seq = 2;
int32 messageType = 3;
string cause = 4;
google.protobuf.Any returnVal = 5;
map<string, string> responseValues = 6;
Pb3Exception exception = 7;
}

message Pb3Exception {
string cause = 1;
string detailMessage = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import com.dianping.pigeon.remoting.common.codec.protobuf.Protobuf3Serializer;
import org.apache.commons.lang.ClassUtils;

import com.dianping.pigeon.extension.ExtensionLoader;
Expand Down Expand Up @@ -49,6 +50,7 @@ public static void init() {
registerSerializer(SerializerType.HESSIAN1, new Hessian1Serializer());
registerSerializer(SerializerType.PROTO, new ProtostuffSerializer());
registerSerializer(SerializerType.THRIFT, new ThriftSerializer());
registerSerializer(SerializerType.PROTOBUF3, new Protobuf3Serializer());

try {
registerSerializer(SerializerType.FST, new FstSerializer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public enum SerializerType {

PROTOBUF((byte) 9, "protobuf"),

THRIFT((byte) 10, "thrift"),;
THRIFT((byte) 10, "thrift"),

PROTOBUF3((byte) 11, "protobuf3");

private byte code;
private String name;
Expand Down Expand Up @@ -54,6 +56,8 @@ public static SerializerType getSerializerType(byte code) {
return PROTOBUF;
case 10:
return THRIFT;
case 11:
return PROTOBUF3;
default:
throw new IllegalArgumentException("invalid serializerType code: " + code);

Expand Down Expand Up @@ -108,6 +112,10 @@ public static boolean isThrift(byte code) {
return THRIFT.getCode() == code;
}

public static boolean isProtobuf3(byte code) {
return PROTOBUF3.getCode() == code;
}

public static boolean isInternalThrift(String desc) {
return INTERNAL_THRIFT.getName().equals(desc);
}
Expand Down Expand Up @@ -143,5 +151,9 @@ public static boolean isProtobuf(String desc) {
public static boolean isThrift(String desc) {
return THRIFT.getName().equals(desc);
}

public static boolean isProtobuf3(String desc) {
return PROTOBUF3.getName().equals(desc);
}

}
Loading

0 comments on commit a138c43

Please sign in to comment.