Skip to content

Commit

Permalink
Merge pull request #4 from zero88/release/0.5.3
Browse files Browse the repository at this point in the history
Release/0.5.3
  • Loading branch information
zero88 authored Dec 16, 2020
2 parents cc315f4 + d308be5 commit d7bf8b3
Show file tree
Hide file tree
Showing 81 changed files with 286 additions and 302 deletions.
7 changes: 2 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'T: defect'
assignees: ''
name: Bug report about: Create a report to help us improve title: ''
labels: 'T: defect' assignees: ''

---

Expand Down
7 changes: 2 additions & 5 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'T: Feature'
assignees: ''
name: Feature request about: Suggest an idea for this project title: ''
labels: 'T: Feature' assignees: ''

---

Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog

## [v0.5.2](https://github.com/zero88/blueprint/tree/release/0.5.1) (2020-12-16)
## [v0.5.3](https://github.com/zero88/blueprint/tree/release/0.5.3) (2020-12-16)

### Changes

- Refactor ErrorCode and Exception

## [v0.5.2](https://github.com/zero88/blueprint/tree/release/0.5.2) (2020-12-16)

### Changes

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ A Vertx framework for microservice
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=zero88_msa-blueprint&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=zero88_msa-blueprint)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=zero88_msa-blueprint&metric=coverage)](https://sonarcloud.io/dashboard?id=zero88_msa-blueprint)


## Overview
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public final class BlueprintConfig implements IConfig {
private AppConfig appConfig = new AppConfig();

/**
* Create {@link BlueprintConfig} with {@link AppConfig}, default {@link DeployConfig} and without {@link SystemConfig}
* Create {@link BlueprintConfig} with {@link AppConfig}, default {@link DeployConfig} and without {@link
* SystemConfig}
*
* @param appConfig Given app config
* @return BlueprintConfig instance
Expand Down
53 changes: 27 additions & 26 deletions base/src/main/java/io/github/zero88/msa/bp/BlueprintLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public final class BlueprintLauncher extends Launcher {

private BlueprintConfig config;
private VertxOptions options;
// private IClusterDelegate clusterDelegate;
// private IClusterDelegate clusterDelegate;

public static void main(String[] args) {
new BlueprintLauncher().dispatch(args);
Expand All @@ -48,7 +48,8 @@ public void afterConfigParsed(JsonObject config) {
if (logger.isDebugEnabled()) {
logger.debug("CONFIG::INPUT: {}", config.encode());
}
BlueprintConfig fileConfig = IConfig.merge(Configs.loadJsonConfig("system.json"), config, BlueprintConfig.class);
BlueprintConfig fileConfig = IConfig.merge(Configs.loadJsonConfig("system.json"), config,
BlueprintConfig.class);
Vertx dummy = Vertx.vertx();
this.config = new ConfigProcessor(dummy).override(fileConfig.toJson(), false, true).orElse(fileConfig);
dummy.close();
Expand All @@ -72,11 +73,12 @@ public void afterStartingVertx(Vertx vertx) {
String addr = config.getSystemConfig().getClusterConfig().getListenerAddress();
ClusterManager clusterManager = this.options.getClusterManager();
if (Strings.isNotBlank(addr)) {
// clusterManager.nodeListener(new ClusterNodeListener(clusterDelegate,
// SharedDataDelegate.getEventController(vertx,
// this.getClass()
// .getName()),
// addr));
// clusterManager.nodeListener(new ClusterNodeListener(clusterDelegate,
// SharedDataDelegate
// .getEventController(vertx,
// this.getClass()
// .getName()),
// addr));
}
}
super.afterStartingVertx(vertx);
Expand Down Expand Up @@ -125,7 +127,7 @@ private AppConfig mergeAppConfig(DeploymentOptions deploymentOptions) {

private VertxOptions reloadVertxOptions(VertxOptions vertxOptions) {
configEventBus(vertxOptions);
// configCluster(vertxOptions);
// configCluster(vertxOptions);
final Entry<Long, TimeUnit> e1 = getSystemProp("vertx.blockedThreadCheckInterval",
VertxOptions.DEFAULT_BLOCKED_THREAD_CHECK_INTERVAL,
"vertx.blockedThreadCheckIntervalUnit",
Expand Down Expand Up @@ -175,22 +177,21 @@ private void configEventBus(VertxOptions options) {
options.setEventBusOptions(option);
}

// private void configCluster(VertxOptions options) {
// logger.info("Setup Cluster...");
// ClusterConfig clusterCfg = config.getSystemConfig().getClusterConfig();
// if (Objects.isNull(clusterCfg) || !clusterCfg.isActive()) {
// logger.info("Cluster is not activated");
// return;
// }
// logger.info("Configure Cluster with options: {}", clusterCfg.toJson());
// logger.info("Cluster type: {}", clusterCfg.getType());
// options.setClustered(true);
// options.setHAEnabled(clusterCfg.isHa());
// this.clusterDelegate = ClusterRegistry.instance().getClusterDelegate(clusterCfg.getType());
// if (Objects.isNull(this.clusterDelegate)) {
// throw new EngineException("Cannot load cluster type: " + clusterCfg.getType());
// }
// options.setClusterManager(this.clusterDelegate.initClusterManager(clusterCfg));
// }

// private void configCluster(VertxOptions options) {
// logger.info("Setup Cluster...");
// ClusterConfig clusterCfg = config.getSystemConfig().getClusterConfig();
// if (Objects.isNull(clusterCfg) || !clusterCfg.isActive()) {
// logger.info("Cluster is not activated");
// return;
// }
// logger.info("Configure Cluster with options: {}", clusterCfg.toJson());
// logger.info("Cluster type: {}", clusterCfg.getType());
// options.setClustered(true);
// options.setHAEnabled(clusterCfg.isHa());
// this.clusterDelegate = ClusterRegistry.instance().getClusterDelegate(clusterCfg.getType());
// if (Objects.isNull(this.clusterDelegate)) {
// throw new EngineException("Cannot load cluster type: " + clusterCfg.getType());
// }
// options.setClusterManager(this.clusterDelegate.initClusterManager(clusterCfg));
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
public @interface ClusterDelegate {
}
public @interface ClusterDelegate {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

public final class ClusterException extends EngineException {

public static final ErrorCode CLUSTER_ERROR = new ErrorCode("CLUSTER_ERROR");
public static final ErrorCode CODE = ErrorCode.parse("CLUSTER_ERROR");

public ClusterException(String message, Throwable e) {
super(CLUSTER_ERROR, message, e);
super(CODE, message, e);
}

public ClusterException(String message) { this(message, null); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
public enum ClusterType implements Shareable, Serializable {

HAZELCAST, ZOOKEEPER, INFINISPAN, IGNITE, KAFKA

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.vertx.core.Future;
import io.vertx.core.Handler;


/**
* Represents a container consists a list of {@code Verticle unit} to startup application
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public abstract class UnitVerticle<C extends IConfig, T extends UnitContext> ext

/**
* For test independent
*
* @param sharedKey shared key
* @param testDir test dir
* @param testDir test dir
*/
protected void injectTest(String sharedKey, Path testDir) {
this.registerSharedKey(Strings.isBlank(sharedKey) ? toString() : sharedKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

/**
* Marks class method to handle event type.
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
public enum EventPattern implements Serializable {

PUBLISH_SUBSCRIBE, POINT_2_POINT, REQUEST_RESPONSE

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ default Single<EventMessage> request(@NonNull DeliveryEvent event) {
/**
* Send message with delivery options then return single response message
*
* @param address Address
* @param message Event message
* @param address Address
* @param message Event message
* @param deliveryOptions delivery options
* @return response message
* @see EventMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

public final class AlreadyExistException extends BlueprintException {

public static final ErrorCode CODE = ErrorCode.ALREADY_EXIST;

public AlreadyExistException(String message, Throwable e) {
super(ErrorCode.ALREADY_EXIST, message, e);
super(CODE, message, e);
}

public AlreadyExistException(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

public final class BeingUsedException extends BlueprintException {

public static final ErrorCode CODE = ErrorCode.parse("BEING_USED");

public BeingUsedException(String message, Throwable e) {
super(ErrorCode.BEING_USED, message, e);
super(CODE, message, e);
}

public BeingUsedException(String message) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

public final class CommunicationProtocolException extends BlueprintException {

public static final ErrorCode CODE = ErrorCode.parse("COMMUNICATION_PROTOCOL_ERROR");

public CommunicationProtocolException(String message, Throwable e) {
super(ErrorCode.COMMUNICATION_PROTOCOL_ERROR, message, e);
super(CommunicationProtocolException.CODE, message, e);
}

public CommunicationProtocolException(String message) { this(message, null); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

public final class ConflictException extends BlueprintException {

public static final ErrorCode CODE = ErrorCode.parse("CONFLICT_ERROR");

public ConflictException(String message, Throwable e) {
super(ErrorCode.CONFLICT_ERROR, message, e);
super(CODE, message, e);
}

public ConflictException(String message) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
*/
public class EngineException extends BlueprintException {

public static final ErrorCode CODE = ErrorCode.parse("ENGINE_ERROR");

public EngineException(String message, Throwable e) {
super(ErrorCode.ENGINE_ERROR, message, e);
super(CODE, message, e);
}

public EngineException(String message) { this(message, null); }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.zero88.msa.bp.exceptions;

import java.util.Objects;

import io.github.zero88.msa.bp.dto.EnumType;
import io.github.zero88.msa.bp.dto.EnumType.AbstractEnumType;

Expand All @@ -11,27 +13,13 @@
@Getter
public final class ErrorCode extends AbstractEnumType implements io.github.zero88.exceptions.ErrorCode, EnumType {

public static final ErrorCode CONFLICT_ERROR = new ErrorCode("CONFLICT_ERROR");
public static final ErrorCode DESIRED_ERROR = new ErrorCode("DESIRED_ERROR");
public static final ErrorCode ALREADY_EXIST = new ErrorCode("ALREADY_EXIST");
public static final ErrorCode NOT_FOUND = new ErrorCode("NOT_FOUND");
public static final ErrorCode SECURITY_ERROR = new ErrorCode("SECURITY_ERROR");
public static final ErrorCode AUTHENTICATION_ERROR = new ErrorCode("AUTHENTICATION_ERROR");
public static final ErrorCode INSUFFICIENT_PERMISSION_ERROR = new ErrorCode("INSUFFICIENT_PERMISSION_ERROR");
public static final ErrorCode HTTP_ERROR = new ErrorCode("HTTP_ERROR");
public static final ErrorCode SERVICE_ERROR = new ErrorCode("SERVICE_ERROR");
public static final ErrorCode INITIALIZER_ERROR = new ErrorCode("INITIALIZER_ERROR");
public static final ErrorCode ENGINE_ERROR = new ErrorCode("ENGINE_ERROR");
public static final ErrorCode CLUSTER_ERROR = new ErrorCode("CLUSTER_ERROR");
public static final ErrorCode EVENT_ERROR = new ErrorCode("EVENT_ERROR");
public static final ErrorCode DATABASE_ERROR = new ErrorCode("DATABASE_ERROR");
public static final ErrorCode TIMEOUT_ERROR = new ErrorCode("TIMEOUT_ERROR");
public static final ErrorCode NETWORK_ERROR = new ErrorCode("NETWORK_ERROR");
public static final ErrorCode COMMUNICATION_PROTOCOL_ERROR = new ErrorCode("COMMUNICATION_PROTOCOL_ERROR");
public static final ErrorCode BEING_USED = new ErrorCode("BEING_USED");
public static final ErrorCode SERVICE_NOT_FOUND = new ErrorCode("SERVICE_NOT_FOUND");

public ErrorCode(String code) {

private ErrorCode(String code) {
super(code);
}

Expand All @@ -45,4 +33,21 @@ public static ErrorCode parse(String code) {
return EnumType.factory(code, ErrorCode.class);
}

public int hashCode() {
return this.code().hashCode();
}

public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (o instanceof String) {
return Objects.equals(this.code(), o);
}
if (!(o instanceof io.github.zero88.exceptions.ErrorCode)) {
return false;
}
return Objects.equals(this.code(), ((io.github.zero88.exceptions.ErrorCode) o).code());
}

}
Loading

0 comments on commit d7bf8b3

Please sign in to comment.