Ratpack Production Tunings
# cat /etc/security/limits.conf
* hard nofile 500000
* soft nofile 500000
root hard nofile 500000
root soft nofile 500000
# cat /etc/security/limits.conf
* hard nofile 500000
* soft nofile 500000
root hard nofile 500000
root soft nofile 500000
/** | |
* The `Promise#map` method is used to retrieve | |
* a value asynchronously (via a `Promise`) and | |
* transform it synchronous to a new value. | |
*/ | |
class MappingSpec extends Specification { | |
@AutoCleanup | |
ExecHarness harness = ExecHarness.harness() |
import com.google.inject.Inject | |
import com.google.inject.Scopes | |
import org.reactivestreams.Publisher | |
import ratpack.exec.ExecController | |
import ratpack.form.Form | |
import ratpack.func.Function | |
import ratpack.groovy.Groovy | |
import ratpack.guice.Guice | |
import ratpack.server.RatpackServer | |
import ratpack.server.ServerConfig |
#!/bin/sh | |
find . -iname "*.java" -exec sed s/\;$// {} \; |
apply plugin: 'groovy' | |
apply plugin: 'idea' | |
repositories { | |
maven { url "https://dl.bintray.com/danveloper/maven" } | |
} | |
dependencies { | |
compile 'com.github.danveloper.ast:ignore-exceptions-ast:1.0.0-rc-2' | |
} |
@GrabResolver(name='netty', root='http://clinker.netty.io/nexus/content/repositories/snapshots') | |
@Grab('io.ratpack:ratpack-groovy:0.9.13-SNAPSHOT') | |
import ratpack.handling.Handler | |
import ratpack.server.* | |
RatpackServer.of { spec -> spec | |
.config(ServerConfig.noBaseDir()) | |
.handler { | |
{ ctx -> ctx.render "Hello World!" } as Handler | |
} |
buildscript {
repositories {
jcenter()
maven { url "http://oss.jfrog.org/oss-snapshot-local" }
maven { url "http://clinker.netty.io/nexus/content/repositories/snapshots" }
}
dependencies {
import java.net.ServerSocket | |
def socket = 8281, password = "danrulz" | |
enum Database { | |
INSTANCE; | |
def table = [:] | |
def shortCodeTable = [:] | |
def insert = { String url -> | |
Sequence.INSTANCE.counter++ | |
def id = Sequence.INSTANCE.counter | |
def shortCode = new BigInteger(id).toString(36)+BigInteger.valueOf(Math.round(Math.random()*1000)).toString(36) |
package com.danveloper.providers | |
import com.danveloper.support.ApplicationHolder as AH | |
import org.hibernate.SessionFactory as SF | |
public interface Provider<T> { | |
T get() | |
} | |
class Support { |
List.metaClass.collapse = {-> | |
def start,end | |
def reverse = delegate[0]?.getAt(0)-delegate[0]?.getAt(-1) > 0 | |
def expanded = delegate.flatten().unique().sort() | |
def result = (reverse ? expanded.reverse() : expanded).inject([]) { l, n -> | |
start = start == null ? n : start | |
end = end == null ? n : end | |
if ((reverse?n+1:n-1)==end) { | |
end = n |