ChangeLog を書く際によく使われる英語をまとめました。
ほとんど引用です。
class Respond extends Service[Request, Response] with Logger { | |
def apply(request: Request) = { | |
try { | |
request.method -> Path(request.path) match { | |
case GET -> Root / "todos" => Future.value { | |
val data = Todos.allAsJson | |
debug("data: %s" format data) | |
Responses.json(data, acceptsGzip(request)) | |
} | |
case GET -> Root / "todos" / id => Future.value { |
def index(id:String) = Action { | |
getFirstData(id) | |
} | |
private def getFirstData(id:String) = { | |
Cache.get(id) match { | |
case Some(id2) => getSecondData(id2) | |
case None => NotFound | |
} | |
} | |
private def getSecondData(id2:String) = { |
class Hoge() {}; var hoge = List(new Hoge()); hoge foldLeft(Map[String, Hoge]()) ( (map:Map[String,Hoge], hoge:Hoge) => map + ("hoge" -> hoge) ); |
import com.twitter.finagle.http.path._ | |
import com.twitter.finagle.http.service.RoutingService | |
import com.twitter.finagle.http.{Request, Response, RichHttp, Http} | |
import com.twitter.finagle.{Service, SimpleFilter} | |
import org.jboss.netty.handler.codec.http._ | |
import org.jboss.netty.handler.codec.http.HttpResponseStatus._ | |
import org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1 | |
import org.jboss.netty.buffer.ChannelBuffers.copiedBuffer | |
import org.jboss.netty.util.CharsetUtil.UTF_8 | |
import com.twitter.util.Future |
object RetryUtil { | |
case class RetryException(throwables: List[Throwable]) extends Exception | |
def retry[T](retryLimit: Int, retryInterval: Int, shouldCatch: Throwable => Boolean)(f: => T): T = { | |
// @annotation.tailrec | |
def _retry( errors: List[Throwable], f: => T):T = { | |
try { | |
f | |
} catch { |
// カリー化された定義の利点その1 | |
// 擬似的な制御構文を作るのに使える | |
// | |
// 以下の関数maybeは、maybe(条件){ 式 } のような使い方ができる。 | |
// 条件が真なら、式の実行結果をSomeに包んでSome[A]を返し、 | |
// 偽ならばNoneを返す | |
scala> def maybe[A](cond: => Boolean)(f: => A):Option[A] = if(cond) Some(f) else None | |
maybe: [A](cond: => Boolean)(f: => A)Option[A] | |
scala> maybe(true){ util.Random.nextPrintableChar } |
#!/bin/bash | |
# Create git hook on stash server | |
# Exit script on error | |
set -e | |
# Define the function that renders super awesome header | |
renderHeader () { | |
HEADER=$1 | |
printf "\n\n" |
メトリクス Web API(JSON) メトリクス
Play2アプリ ----------> guardian-management-play ------------> Rubyスクリプト --> gmetricコマンド ----------> Webサーバ内のgmond --------> 集約先のgmond/gmetad
Play2アプリでMetricsを計測して、それをJSONファイルとしてWeb API経由で提供するところまでやる。