Skip to content

Instantly share code, notes, and snippets.

View pmlopes's full-sized avatar
🏠
Working from home

Paulo Lopes pmlopes

🏠
Working from home
View GitHub Profile
@pmlopes
pmlopes / HelloSpec.groovy
Created June 23, 2015 09:37
Spock and Vertx3
import io.vertx.core.Vertx
import spock.lang.Shared
import spock.lang.Specification
import spock.util.concurrent.BlockingVariable
class HelloSpockSpec extends Specification {
@Shared
def Vertx vertx = Vertx.vertx()
@pmlopes
pmlopes / VertxOauth2Client.java
Created March 20, 2017 19:27
How to consume a Oauth2 project API with Vert.x
// setup an Oauth2 provider for Keycloak
OAuth2Auth oauth2 = KeycloakAuth.create(vertx, OAuth2FlowType.PASSWORD, config());
// credentials
JsonObject credentials = new JsonObject()
.put("username", username)
.put("password", password);
// create an WebClient to make request
final WebClient client = WebClient.create(vertx);
@pmlopes
pmlopes / Handler.java
Created June 27, 2018 08:49
Graal JS Overload issue
@FunctionalInterface
public interface Handler<T> {
void handle(T value);
}
/*
* Copyright (c) 2011-2015 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
/// <reference types="@vertx/core/runtime" />
// @ts-check
const util = require('util');
import {Router} from '@vertx/web';
import {PgClient, Tuple} from '@reactiverse/reactive-pg-client';
import {PgPoolOptions} from '@reactiverse/reactive-pg-client/options';
const SELECT_WORLD = "SELECT id, randomnumber from WORLD where id=$1";
package io.vertx.benchmark;
import io.reactiverse.pgclient.*;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.json.*;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
@pmlopes
pmlopes / PSQLVerticle.java
Last active December 25, 2019 02:38
Using PostgreSQL JSON with Vert.x3
package io.vertx.blog;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.jdbc.JDBCClient;
import io.vertx.ext.sql.SQLConnection;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.handler.BodyHandler;
Unhandled exception caused by org.graalvm.polyglot.PolyglotException: java.lang.AssertionError: Invalid libray usage. Cached library must be adopted by a RootNode before it is executed.
at org.graalvm.truffle/com.oracle.truffle.api.object.DynamicObjectGen$DynamicDispatchLibraryExports$Cached.dispatch(DynamicObjectGen.java:154)
at com.oracle.truffle.js.runtime.builtins.JSClassGen$InteropLibraryExports$Cached.accepts(JSClassGen.java:119)
at org.graalvm.truffle/com.oracle.truffle.api.interop.InteropLibrary$Asserts.accepts(InteropLibrary.java:1594)
at org.graalvm.truffle/com.oracle.truffle.polyglot.ToHostNodeGen.execute(ToHostNodeGen.java:45)
at org.graalvm.truffle/com.oracle.truffle.polyglot.TargetMappingNode$SingleMappingNode.doDefault(TargetMappingNode.java:145)
at org.graalvm.truffle/com.oracle.truffle.polyglot.TargetMappingNodeGen$SingleMappingNodeGen.execute(TargetMappingNodeGen.java:159)
at org.graalvm.truffle/com.oracle.truffle.polyglot.HostExecuteNode$TargetMappingType.execute(HostExecuteNode.java