Skip to content

Commit

Permalink
Removed nested failure actions. Use Logger.
Browse files Browse the repository at this point in the history
  • Loading branch information
VaughnVernon committed Sep 18, 2019
1 parent bf62a0a commit 21e6638
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 27 deletions.
46 changes: 46 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
language: java
dist: trusty
before_install:
- cd ${TRAVIS_BUILD_DIR}/..
- git clone --depth=50 --branch=master https://github.com/vlingo/vlingo-common.git
- cd vlingo-common && mvn install -DskipTests=true
- cd ${TRAVIS_BUILD_DIR}/..
- git clone --depth=50 --branch=master https://github.com/vlingo/vlingo-actors.git
- cd vlingo-actors && mvn install -DskipTests=true
- cd ${TRAVIS_BUILD_DIR}/..
- git clone --depth=50 --branch=master https://github.com/vlingo/vlingo-wire.git
- cd vlingo-wire && mvn install -DskipTests=true
- cd ${TRAVIS_BUILD_DIR}/..
- git clone --depth=50 --branch=master https://github.com/vlingo/vlingo-cluster.git
- cd vlingo-cluster && mvn install -DskipTests=true
- cd ${TRAVIS_BUILD_DIR}/..
- git clone --depth=50 --branch=master https://github.com/vlingo/vlingo-symbio.git
- cd vlingo-symbio && mvn install -DskipTests=true
- cd ${TRAVIS_BUILD_DIR}/..
- git clone --depth=50 --branch=master https://github.com/vlingo/vlingo-lattice.git
- cd vlingo-lattice && mvn install -DskipTests=true
- cd ${TRAVIS_BUILD_DIR}
services:
- postgresql
addons:
postgresql: '10.10'
before_script:
- psql -c "CREATE DATABASE vlingo_schemata;" -U postgres
- psql -c "CREATE USER vlingo_schemata WITH PASSWORD 'vlingo123' LOGIN NOSUPERUSER INHERIT
CREATEDB NOCREATEROLE NOREPLICATION;" -U postgres
script:
- mvn install
deploy:
provider: bintray
file: bintray.json
skip_cleanup: true
user: vaughnvernon
on:
branch: master
key:
secure: ViFqWpgm/6F8AAYxdZrU8zcAHjDxEc/rzGk2xKWtleJPiOlRDB3r+zH66hfsQP78jeOaQ9ErdItqIS9SCE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e2zs6yaE0Q2WpM1ULLnpgzvxSlyGdJf2lf6w1DRoaoFF7B3cXqXMNF4X8N+rmJw8WcG4y7nndtuuIGxoCE+/aQWZCRB9Z7sByv2plaDuaXt/mgnA8lHCR/CZgAqgYRHHYEA9T8Jk+Fp20bC9kKd6j9Oa8kDaIpPQwy/I5jj536g/msctJykuFBh2nlJdCNFyVgX/xegDE2r0IC/g=
notifications:
slack:
secure: AgEmeaQl5W+pb11ThGexSGdjQGHnkpOmRiQRBQbpcbG+B9JrItWirboKbLN4MlLMFz+sAX3IBI9LY09IcWT/ycmn4rXDIdfdfzH3edS5PXUkUZ3Ew8IaQ641OqZqhg/CbvacD/Pyv2gGCvF5UfRfKVrsNa7rQkGefP1mkQ4Z71bVxe+sokVDZYyInwVD5VuxIDCsmuM6AsbpQo8vGa6LvMlnqNhC5AYuOwWRntqrb6ncNYwuPUw5zT5cG43qr3iIlBP9uOr7+wgg1cAysMs3kd2uyq5g0hKvKY/HqW++BO7qWNLwnBdTcU0ibbr17znXfbgSfhG0shHWrzVE81hkAMpVD5uxWA1O6+VFnXvhicGQyZPR9zD4tyO1cge9KulU3xW2ZSO+vWJ0LahaszngFRaMETl7JtVddYJ8uT0Bsq8YyEaP9yOrXggt+MTp2XxtmTFCFdLs2T2BG7Ujz6+DsxbghYdTYN6lmhyZZSzPKqz/5/gpyo6HbP0byc4LQUM59RsG+sLckh9/FQHBAPwKgplcwiszMik/a2KnAlBrTasoXFWkfqeXrQJnZuDZp+JMs5Z9UMZeaGKrn+si8olBcMYEKOeoGsy2UrbSOMvwlew94C+6gSLfKOKhDswsCuMEj6B4ZAl4L1T3cvRRrVyViilTKbzhs9b2QBNXBBktJ2k=
14 changes: 14 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.1'

services:
postgres:
image: postgres:latest
restart: always
ports:
- '5432:5432'
environment:
POSTGRES_USER: vlingo_schemata
POSTGRES_PASSWORD: vlingo123

volumes:
vlingo_schemata_postgres:
4 changes: 4 additions & 0 deletions pgbounce.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# bounce the docker volume vlingo_schemata_postgres in the docker-compose.yml
docker-compose -p "dev" down
docker volume rm vlingo_schemata_postgres
docker-compose -p "dev" up -d
37 changes: 10 additions & 27 deletions src/main/java/io/vlingo/schemata/resource/CodeResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;

import io.vlingo.actors.Logger;
import io.vlingo.actors.Stage;
import io.vlingo.actors.World;
import io.vlingo.common.Completes;
Expand Down Expand Up @@ -48,63 +49,45 @@
// header: Authorization: VLINGO-SCHEMATA source=<some-hash-value> dependent=<some-hash-value>
//
public class CodeResource extends ResourceHandler {
private final Logger logger;
private final Stage stage;

public CodeResource(final World world) {
this.stage = world.stageNamed(StageName);
this.logger = world.defaultLogger();
}

public Completes<Response> queryCodeForLanguage(final String reference, final String language) {
final Collector collector = given(context().request, reference);

return Queries.forCode()
.schemaVersionFor(collector.authorization, collector.path, collector)
.otherwise(failure -> {
System.out.println("FAILED ON VERSION: " + failure);
return failure;
})
.andThenTo(version -> {
System.out.println("VERSION: " + version);
logger.debug("VERSION: " + version);
return queryContextWith(collector.contextIndentities, collector);
})
.otherwise(failure -> {
System.out.println("FAILED ON QUERY CONTEXT: " + failure);
return failure;
})
.andThenTo(context -> {
System.out.println("CONTEXT: " + context);
logger.debug("CONTEXT: " + context);
return validateContext(context, collector);
})
.otherwise(failure -> {
System.out.println("FAILED ON VALIDATE CONTEXT: " + failure);
return failure;
})
.andThenTo(context -> {
System.out.println("COMPILING: " + collector.schemaVersion().specification);
logger.debug("COMPILING: " + collector.schemaVersion().specification);
return compile(collector.schemaVersion(), language);
})
.otherwise(failure -> {
System.out.println("FAILED ON COMPILE: " + failure);
return failure;
})
.andThenTo(code -> {
System.out.println("CODE: \n" + code);
logger.debug("CODE: \n" + code);
return recordDependency(code, collector);
})
.otherwise(failure -> {
System.out.println("FAILED ON RECORD DEPENDENCY: " + failure);
return failure;
})
.andThenTo(code -> {
System.out.println("SUCCESS: \n" + code);
logger.debug("SUCCESS: \n" + code);
return Completes.withSuccess(Response.of(Ok, code));
})
.otherwise(failure -> {
System.out.println("FAILED: " + failure);
logger.error("FAILED: " + failure);
return Response.of(InternalServerError);
})
.recoverFrom(exception -> {
System.out.println("EXCEPTION: " + exception);
logger.error("EXCEPTION: " + exception, exception);
return Response.of(BadRequest, exception.getMessage());
});
}
Expand Down

0 comments on commit 21e6638

Please sign in to comment.