KengoTODA / brownie

A distributed video converter
6 stars 0 forks source link

Introduce Circuit Breaker Pattern #1

Closed KengoTODA closed 8 years ago

KengoTODA commented 8 years ago

If we stop using --link, application server may be launched before datastore becomes ready. To support this case, it is better to introduce Circuit Breaker Pattern to data access layers.

KengoTODA commented 8 years ago

https://github.com/vert-x3/vertx-circuit-breaker

KengoTODA commented 8 years ago

Circuit Breaker Pattern is not for checking connectivity data access layers, it should exist at border between bounded contexts.

KengoTODA commented 8 years ago

It might be better to create a common class which helps microservice to generate HTTP client with Circuit Breaker Pattern and Service Discovery. Currently we have copy-pasted code like below:

    private Single<HttpClient> createHttpClientForFileStorage(Future<Void> closed) {
        return discovery.getRecordObservable(r -> r.getName().equals("file-storage"))
            .map(discovery::getReference)
            .flatMap(reference -> {
                HttpClient client = new HttpClient(reference.get());
                closed.setHandler(ar -> {
                    reference.release();
                });
                return Observable.just(client);
            })
            .toSingle();
    }