Skip to content

Commit

Permalink
注释补充
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghanzheng committed Jul 14, 2023
1 parent e302db1 commit 0509b33
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import java.util.Map;

/**
* 连接服务
* 连接服务
* <p>
* 表示服务实例信息
* A server can be connect.
*/
public interface ConnectionServer {

Expand All @@ -17,59 +17,19 @@ static String url(ConnectionServer server) {
return server.getHost() + ":" + server.getPort();
}

/**
* 获得服务实例 id
*
* @return 服务实例 id
*/
String getInstanceId();

/**
* 获得服务 id
*
* @return 服务 id
*/
String getServiceId();

/**
* 获得 host
*
* @return host
*/
String getHost();

/**
* 获得 port
*
* @return port
*/
int getPort();

/**
* 获得元数据
*
* @return 元数据
*/
Map<String, String> getMetadata();

/**
* 获得 {@link URI}
*
* @return {@link URI}
*/
URI getUri();

/**
* 获得 Scheme
*
* @return Scheme
*/
String getScheme();

/**
* 是否安全的
*
* @return 是否安全的
*/
boolean isSecure();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import java.util.Map;

/**
* {@link ConnectionServer} 的默认实现
* {@link ConnectionServer} 的默认实现。
* <p>
* Default impl of {@link ConnectionServer}.
*/
@Data
public class ConnectionServerImpl implements ConnectionServer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,121 @@
import java.util.List;

/**
* {@link ConnectionServer} 提供者
* 连接服务管理器。
* <p>
* Management of connectable server.
*/
public interface ConnectionServerManager {

/**
* 添加服务。
* <p>
* Add a server.
*/
default void add(ConnectionServer server, ConnectionLoadBalanceConcept concept) {
throw new UnsupportedOperationException();
}

/**
* 添加服务。
* <p>
* Add a server.
*/
default void add(ConnectionServer server) {
add(server, null);
}

/**
* 移除服务。
* <p>
* Remove a server.
*/
default void remove(ConnectionServer server, ConnectionLoadBalanceConcept concept) {
throw new UnsupportedOperationException();
}

/**
* 移除服务。
* <p>
* Remove a server.
*/
default void remove(ConnectionServer server) {
remove(server, null);
}

/**
* 清空服务。
* <p>
* Clear servers.
*/
default void clear(ConnectionLoadBalanceConcept concept) {
throw new UnsupportedOperationException();
}

/**
* 清空服务。
* <p>
* Clear servers.
*/
default void clear() {
clear(null);
}

/**
* 比较两个服务是否相等。
* <p>
* Compare whether two services are equal.
*/
default boolean isEqual(ConnectionServer server1, ConnectionServer server2, ConnectionLoadBalanceConcept concept) {
return server1.getHost().equals(server2.getHost()) && server1.getPort() == server2.getPort();
}

/**
* 比较两个服务是否相等。
* <p>
* Compare whether two services are equal.
*/
default boolean isEqual(ConnectionServer server1, ConnectionServer server2) {
return isEqual(server1, server2, null);
}

/**
* 获得本地服务。
* <p>
* Get local server.
*/
ConnectionServer getLocal(ConnectionLoadBalanceConcept concept);

/**
* 获得本地服务。
* <p>
* Get local server.
*/
default ConnectionServer getLocal() {
return getLocal(null);
}

/**
* 获得需要连接的服务。
* <p>
* Get servers need connect.
*/
List<ConnectionServer> getConnectionServers(ConnectionLoadBalanceConcept concept);

/**
* 获得需要连接的服务。
* <p>
* Get servers need connect.
*/
default List<ConnectionServer> getConnectionServers() {
return getConnectionServers(null);
}

/**
* 连接服务管理器代理。
* <p>
* Delegate of server manager.
*/
@Getter
@RequiredArgsConstructor
class Delegate implements ConnectionServerManager {
Expand All @@ -64,7 +131,7 @@ class Delegate implements ConnectionServerManager {
private final ConnectionServerManager delegate;

public static ConnectionServerManager delegate(ConnectionLoadBalanceConcept concept,
ConnectionServerManager delegate) {
ConnectionServerManager delegate) {
return new Delegate(concept, delegate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

import com.github.linyuzai.connection.loadbalance.core.scope.ScopedFactory;

/**
* 连接管理器工厂。
* <p>
* Factory of server manager.
*/
public interface ConnectionServerManagerFactory extends ScopedFactory<ConnectionServerManager> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import java.util.concurrent.CopyOnWriteArrayList;

/**
* {@link ConnectionServer} 提供者默认实现
* 连接服务管理器简单实现。
* <p>
* Simple impl of server manager.
*/
public class SimpleConnectionServerManager implements ConnectionServerManager {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.github.linyuzai.connection.loadbalance.core.server;

/**
* {@link SimpleConnectionServerManager} 工厂。
* <p>
* Factory of {@link SimpleConnectionServerManager}.
*/
public class SimpleConnectionServerManagerFactory implements ConnectionServerManagerFactory {

@Override
Expand Down

0 comments on commit 0509b33

Please sign in to comment.