通用注解
package com.test.rpc.annotation;
import java.lang.annotation.*;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Contract {
String name();
String description();
}
package com.test.rpc.annotation;
import java.lang.annotation.*;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Implement {
Class contract();
String impCode();
}
package com.test.rpc.annotation;
import java.lang.annotation.*;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Method {
boolean idempotent() default true;
long timeout() default 5000L;
long retryTimes() default 0;
}
package com.test.rpc.annotation;
import java.lang.annotation.*;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Reference {
Class contract();
String version();
}
zookeeper
package com.test.rpc.registry.constants;
public interface ZKConfig {
String ZK_CONNECTION_STRING = "127.0.0.1:2181";
String ZK_REGISTER_PATH = "/rpc_train";
}
package com.test.rpc.registry;
public interface Register {
/**
* 注册中心,注册服务信息
* @param serviceName 服务名称,一般是接口名+版本号
* @param serverAddress 服务地址,一般是ip