Skip to content

Instantly share code, notes, and snippets.

Rowell Belen bytekast

Block or report user

Report or block bytekast

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View java-springboot-monolith.sh
serverless create \
--template-url https://github.com/bytekast/serverless-toolkit/tree/master/templates/java-springboot-monolith \
--path my-springboot-service
cd my-springboot-service
./gradlew clean build # build
./gradlew bootRun # run locally
curl http://localhost:8080/greeting # test locally
serverless deploy # deploy
View task.gradle
task(buildJson) {
doLast {
new File("$buildDir/build.json").newWriter().withWriter { w ->
w << JsonOutput.toJson([distribution: relativePath(jar.archivePath), version: jar.version])
}
}
}
jar.finalizedBy buildJson
@bytekast
bytekast / serverless_create.sh
Last active Feb 26, 2018
create microservice template
View serverless_create.sh
serverless create \
--template-url https://github.com/bytekast/serverless-templates/tree/master/microservice-starter \
--path myservice
@bytekast
bytekast / AbstractEventHandler.groovy
Created Dec 7, 2017
Common Base Handler for Lambda Functions
View AbstractEventHandler.groovy
package com.stedi.platform.lambda
import com.amazonaws.services.lambda.runtime.Context
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.codehaus.groovy.runtime.StackTraceUtils
@Slf4j
@CompileStatic
abstract class AbstractEventHandler implements CommonTrait, AmazonSNSTrait, DataDogTrait, SentryTrait {
@bytekast
bytekast / promiseChaining.groovy
Last active Aug 29, 2017
Chaining Promises in Groovy GPars
View promiseChaining.groovy
final successHandler = { controller.successEvent(context, transmissionUuid, parcel) }
final errorHandler = { Exception e -> controller.errorEvent(context, transmissionUuid, parcel, e) }
task { controller.download(sessionId, parcel) }
.then { download -> controller.save(download, transmissionUuid, parcel) }
.then { download -> controller.forward(download, transmissionUuid, parcel) }
.then { controller.delete(sessionId, parcel.id) }
.then(successHandler, errorHandler)
View build.gradle
apply plugin: 'groovy'
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile(
'org.codehaus.groovy:groovy-all:2.4.7',
View serverless.yml
service: user-service
provider:
name: aws
runtime: java8
memorySize: 1536
timeout: 60
package:
artifact: build/distributions/user-service.zip
View VertxHandler.groovy
package com.serverless
import com.amazonaws.services.lambda.runtime.Context
import com.amazonaws.services.lambda.runtime.RequestHandler
import io.vertx.core.AbstractVerticle
import io.vertx.core.Vertx
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit
View VertxLambdaHandler.groovy
@SpringBootApplication
@ComponentScan
@Log4j
class VertxLambdaHandler implements RequestHandler<Map, Response> {
static void main(String[] args) throws Exception {
LambdaHandler.newInstance().getApplicationContext(args)
}
@Memoized
View loadTest.groovy
@Grab(group='org.codehaus.gpars', module='gpars', version='1.2.1')
import static groovyx.gpars.GParsPool.withPool
withPool(100) {
(1..2000).eachParallel { i ->
def beginTime = System.currentTimeMillis()
def result = 'https://xxxxx.execute-api.us-east-1.amazonaws.com/dev/users'.toURL().text
println "${i}: ${System.currentTimeMillis() - beginTime}"
}
}
You can’t perform that action at this time.