Skip to content

Commit

Permalink
Merge pull request #83 from truthencode/config/documentation
Browse files Browse the repository at this point in the history
Config/documentation
  • Loading branch information
adarro committed Sep 5, 2023
2 parents d7496b2 + cefb67e commit bca2df8
Show file tree
Hide file tree
Showing 133 changed files with 2,418 additions and 988 deletions.
1 change: 1 addition & 0 deletions .bsp/sbt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"sbt","version":"1.6.2","bspVersion":"2.0.0-M5","languages":["scala"],"argv":["/home/adarro/.sdkman/candidates/java/22.0.0.2.r11-grl/bin/java","-Xms100m","-Xmx100m","-classpath","/home/adarro/.sdkman/candidates/sbt/1.6.2/bin/sbt-launch.jar","-Dsbt.script=/home/adarro/.sdkman/candidates/sbt/current/bin/sbt","xsbt.boot.Boot","-bsp"]}
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ buildNumber.properties
# RStudio files
.Rproj.user/

**/.antlr/

# produced vignettes
vignettes/*.html
vignettes/*.pdf
Expand Down Expand Up @@ -80,8 +82,12 @@ qa-tools/qa-tools.iml
/.ensime_cache/
### Gradle template
.gradle
local.properties
build/

# temporary items
testprojects

# Ignore Gradle GUI config
gradle-app.setting

Expand Down Expand Up @@ -195,4 +201,10 @@ rslt.txt
# apache ignite folder
**/ignite/*
# auto generated files
**/version.properties
**/version.properties
incubating/ddo-antlr/src/generated/java/*
local.properties

.quarkus/
/subprojects/common/ddo-modeling/src/main/avro/
/subprojects/common/ddo-core/src/generated/java/io/truthencode/ddo/core/GeneratedVersion.java
32 changes: 32 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/mkdocs.yaml

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
# python:
# install:
# - requirements: docs/requirements.txt
4 changes: 4 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gradle 7.6
dotty 3.2.1
scala 12.13.10
kotlin 1.7.10
4 changes: 4 additions & 0 deletions archived/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Archived Projects

These are subprojects that aren't currently incubated or slated for any active development.
They may eventually be removed or revived.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
plugins {
id("scala-library-profile")
`maven-publish`
id("be.vbgn.ci-detect") version "0.5.0"
}

repositories {
Expand Down Expand Up @@ -55,7 +56,7 @@ val hazelcastVersion: String by project
val junitScalaTestVersion: String by project
val junitPlatformVersion: String by project
val junitLauncherVersion: String by project
val verticesVersion:String by project
val verticesVersion: String by project
val monixVersion: String by project

dependencies {
Expand Down Expand Up @@ -87,7 +88,11 @@ dependencies {
implementation("io.vertx:vertx-mongo-client:$vertxVersion")
implementation("io.vertx:vertx-ignite:$vertxVersion")

implementation(group="io.github.davidgregory084", name="vertices-core_$scalaMajorVersion",version = verticesVersion)
implementation(
group = "io.github.davidgregory084",
name = "vertices-core_$scalaMajorVersion",
version = verticesVersion
)

implementation("io.vertx:vertx-codegen:$vertxVersion")
implementation("io.vertx:vertx-auth-shiro:$vertxVersion")
Expand Down Expand Up @@ -165,6 +170,13 @@ tasks {
withType(Test::class.java) {
useJUnitPlatform {
includeEngines = setOf("scalatest", "junit-jupiter")
if (ci.isCi)
excludeTags = setOf(
"Integration",
"io.truthencode.tags.Integration",
"FunctionOnly",
"io.truthencode.tags.FunctionOnly"
)
testLogging {
events("passed", "skipped", "failed")
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private Server() {
*
* @return the server (type Server) of this Server object.
*/
private synchronized static Server getServer() {
private static synchronized Server getServer() {
if (server == null) {
server = new Server();
}
Expand Down Expand Up @@ -80,16 +80,7 @@ private void initVertxCluster() {
}
});

// Unsure if we need to add shutdownhook for ZK as we did for Hazelcast
// Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// log.info("Shutting down Hazelcast");
// Zookeeper instance = clusterManager.
// if (instance.getPartitionService().isClusterSafe()) {
// IExecutorService svc = instance.getExecutorService(Server.class.getName());
// svc.executeOnAllMembers(new ShutdownMember());
// }
// }));
}


/**
* Internally calls {@link #initVertxCluster()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
public class MyFirstVerticle extends AbstractVerticle {
private static final Logger log = LoggerFactory.getLogger(MyFirstVerticle.class);
private static final String COLLECTION = "whiskies";
public static final String CONTENT_TYPE = "content-type";
public static final String API_WHISKIES_ID = "/api/whiskies/:id";
public static final String APPLICATION_JSON_CHARSET_UTF_8 = "application/json; charset=utf-8";
private MongoClient mongo;

/**
Expand Down Expand Up @@ -112,7 +115,7 @@ private void startWebApp(Handler<AsyncResult<HttpServer>> next) {
routingContext -> {
HttpServerResponse response = routingContext
.response();
response.putHeader("content-type", "text/html")
response.putHeader(CONTENT_TYPE, "text/html")
.end("<h1>Hello from my first Vert.x 3 application</h1>");
});

Expand All @@ -121,12 +124,12 @@ private void startWebApp(Handler<AsyncResult<HttpServer>> next) {
router.get("/api/whiskies").handler(this::getAll);
router.route("/api/whiskies*").handler(BodyHandler.create());
router.post("/api/whiskies").handler(this::addOne);
router.get("/api/whiskies/:id").handler(this::getOne);
router.put("/api/whiskies/:id").handler(this::updateOne);
router.delete("/api/whiskies/:id").handler(this::deleteOne);
router.get(API_WHISKIES_ID).handler(this::getOne);
router.put(API_WHISKIES_ID).handler(this::updateOne);
router.delete(API_WHISKIES_ID).handler(this::deleteOne);
Config conf = ConfigFactory.load("defaults");
int port = conf.getInt("server-info.port");
// Integer port = config().getInteger("http.port", 8080);

log.info(String.format("Creating http server on port (%d)", port));
// Create the HTTP server and pass the "accept" method to the request
// handler.
Expand Down Expand Up @@ -158,7 +161,7 @@ private void completeStartup(AsyncResult<HttpServer> http, Promise<Void> fut) {
@Override
public void stop() {
mongo.close();
// MongoService.Stop();

}

private void addOne(RoutingContext routingContext) {
Expand All @@ -171,8 +174,8 @@ private void addOne(RoutingContext routingContext) {
r -> routingContext
.response()
.setStatusCode(201)
.putHeader("content-type",
"application/json; charset=utf-8")
.putHeader(CONTENT_TYPE,
APPLICATION_JSON_CHARSET_UTF_8)
.end(Json.encodePrettily(whisky.setId(r.result()))));
}

Expand All @@ -196,8 +199,8 @@ private void getOne(RoutingContext routingContext) {
routingContext
.response()
.setStatusCode(200)
.putHeader("content-type",
"application/json; charset=utf-8")
.putHeader(CONTENT_TYPE,
APPLICATION_JSON_CHARSET_UTF_8)
.end(Json.encodePrettily(whisky));
} else {
routingContext.response().setStatusCode(404).end();
Expand All @@ -215,17 +218,17 @@ private void updateOne(RoutingContext routingContext) {
mongo.updateCollection(
COLLECTION,
new JsonObject().put("_id", id), // Select a unique document
// The update syntax: {$set, the json object containing the
// fields to update}
/* The update syntax: {$set, the json object containing the
fields to update} */
new JsonObject().put("$set", json),
v -> {
if (v.failed()) {
routingContext.response().setStatusCode(404).end();
} else {
routingContext
.response()
.putHeader("content-type",
"application/json; charset=utf-8")
.putHeader(CONTENT_TYPE,
APPLICATION_JSON_CHARSET_UTF_8)
.end(Json.encodePrettily(new Whisky(id,
json.getString("name"), json
.getString("origin"))));
Expand Down Expand Up @@ -254,8 +257,8 @@ private void getAll(RoutingContext routingContext) {
.collect(Collectors.toList());
routingContext
.response()
.putHeader("content-type",
"application/json; charset=utf-8")
.putHeader(CONTENT_TYPE,
APPLICATION_JSON_CHARSET_UTF_8)
.end(Json.encodePrettily(whiskies));
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
limitations under the License.
-->
<html>
<!DOCTYPE>
<html lang="en">
<head><title>Welcome to the Sample</title></head>
<body>

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>My Whiskies</h1>
</button>
<div class="row">
<div class="col-md-12">
<table class="table table-striped">
<table class="table table-striped" aria-labelledby="Whiskey bottles">
<thead>
<tr>
<th>#</th>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class EmbeddedMongoVerticleIT {

// will be shared between test methods
@Container
final static MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.1.2"));
static final MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.1.2"));

public VertxOptions getOptions() {
// It can take some time to download the first time!
Expand All @@ -62,23 +62,6 @@ void testContainer() {
assertTrue(mongoDBContainer.isRunning());
}

// static JMongoRunner runner = new JMongoRunner(27017);

// @BeforeAll
// static void setUpDb() {
//
// try {
// runner.start();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }

// @AfterAll
// static void closeDb() {
// runner.stop();
// }

String mongoUrl(MongoDBContainer mongo) {
if (!mongo.isRunning()) {
mongo.start();
Expand All @@ -98,11 +81,6 @@ public void testDeployUsingClassName(Vertx vertx, VertxTestContext testContext)
assertNotNull(id);
vertx.undeploy(id, testContext.succeedingThenComplete());
}));
// ar.onComplete(testContext.succeeding(rslt ->
// testContext.verify(() -> {
// assertTrue(ar.succeeded());
// })));
// });
assertTrue(testContext.awaitCompletion(5, TimeUnit.SECONDS));
if (testContext.failed())
throw testContext.causeOfFailure();
Expand All @@ -116,11 +94,11 @@ public void testEmbeddedMongo(Vertx vertx, VertxTestContext testContext) throws
// Not really sure what to test here apart from start and stop vertx.
vertx.deployVerticle("service:io.vertx.vertx-mongo-embedded-db", testContext.succeeding(deploymentID -> {
assertNotNull(deploymentID);
vertx.undeploy(deploymentID, testContext.succeeding(v -> {
testContext.verify(() -> {
vertx.undeploy(deploymentID, testContext.succeeding(v ->
testContext.verify(() ->
assertNull(v);
});
}));
);
));
}));
assertTrue(testContext.awaitCompletion(5, TimeUnit.SECONDS));
if (testContext.failed())
Expand All @@ -147,8 +125,7 @@ public void testSimpleVerticle(Vertx vertx, VertxTestContext testContext) throws


@Test
void start_http_server(Vertx vertx, VertxTestContext testContext) throws Throwable {
// VertxTestContext testContext = new VertxTestContext();
void startHttpServer(Vertx vertx, VertxTestContext testContext) throws Throwable {

vertx.createHttpServer()
.requestHandler(req -> req.response().end())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ public void start() {
public void stop() {

// You can optionally override the stop method too, if you have some clean-up to do

System.out.println("In OtherVerticle.stop");
java.util.logging.Logger.getLogger(DemoVerticle.class.getName()).warning("In OtherVerticle.stop")

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
public class MongoClientVerticle extends AbstractVerticle {


static final String LABEL_ITEM_ID = "itemId";
static final String LABEL_NAME = "name";
static final String LABEL_PRICE = "price";
static final String SOME_NUMBER = "12345";
static final String LABEL_PRODUCTS = "products";
Logger logger = java.util.logging.Logger.getLogger(MongoClientVerticle.class);

@Override
public void start() throws Exception {
Expand All @@ -30,20 +36,20 @@ public void start() throws Exception {

MongoClient mongoClient = MongoClient.createShared(vertx, mongoconfig);

JsonObject product1 = new JsonObject().put("itemId", "12345").put("name", "Cooler").put("price", "100.0");
JsonObject product1 = new JsonObject().put(LABEL_ITEM_ID, LABEL_SOME_NUMBER).put(LABEL_NAME, "Cooler").put(LABEL_PRICE, "100.0");

mongoClient.save("products", product1)
mongoClient.save(LABEL_PRODUCTS, product1)
.compose(id -> {
System.out.println("Inserted id: " + id);
return mongoClient.find("products", new JsonObject().put("itemId", "12345"));
logger.debug("Inserted id: " + id);
return mongoClient.find(LABEL_PRODUCTS, new JsonObject().put(LABEL_ITEM_ID, LABEL_SOME_NUMBER));
})
.compose(res -> {
System.out.println("Name is " + res.get(0).getString("name"));
return mongoClient.removeDocument("products", new JsonObject().put("itemId", "12345"));
logger.debug("Name is " + res.get(0).getString(LABEL_NAME));
return mongoClient.removeDocument(LABEL_PRODUCTS, new JsonObject().put(LABEL_ITEM_ID, LABEL_SOME_NUMBER));
})
.onComplete(ar -> {
if (ar.succeeded()) {
System.out.println("Product removed ");
logger.debug("Product removed ");
} else {
ar.cause().printStackTrace();
}
Expand Down
Loading

0 comments on commit bca2df8

Please sign in to comment.