Skip to content

Instantly share code, notes, and snippets.

View dpsoft's full-sized avatar

Diego Parra dpsoft

View GitHub Profile
package kamon.netty.playground.http.helloworld
import io.netty.bootstrap.ServerBootstrap
import io.netty.channel.ChannelOption
import io.netty.channel.nio.NioEventLoopGroup
import io.netty.channel.socket.nio.NioServerSocketChannel
import io.netty.util.internal.logging.{InternalLoggerFactory, Slf4JLoggerFactory}
import kamon.Kamon
import kamon.netty.annotation.MetricName
import kamon.netty.playground.HttpHelloWorldServerInitializer
/* =========================================================================================
* Copyright © 2013-2014 the kamon project <http://kamon.io/>
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
TraceLocalKey<String> stringKey = TraceLocal.newTraceLocalKey();
TraceLocal.store(stringKey, "Pepe");
Option<String> retrieve = TraceLocal.retrieve(stringKey); //option
String retrieve = TraceLocal.get(stringKey);
System.out.println(retrieve);
@dpsoft
dpsoft / TraceLocal.scala
Last active August 29, 2015 14:21
TraceLocal
object TraceLocal {
trait TraceLocalKey[T]
trait AvailableToMdc extends TraceLocalKey[String] {
def mdcKey: String
}
object AvailableToMdc {
case class DefaultKeyAvailableToMdc(mdcKey: String) extends AvailableToMdc
@dpsoft
dpsoft / EAM.java
Last active July 23, 2018 15:02
Execute Around Method Pattern: Java 8 vs Scala
import java.util.function.Consumer;
import static java.lang.System.out;
class JavaResource {
private JavaResource() {out.println("created...");}
public void operation1() {out.println("operation 1");}
public void operation2() {out.println("operation 2");}
private void close() { out.println("cleanup");}
public static void use(Consumer<JavaResource> block) {
#!/usr/bin/env python
import argparse
import sys
from clint.textui import progress
from clint.textui import colored
from kazoo.client import KazooClient, KazooState