๐
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.gutefrage | |
import com.twitter.app.App | |
import com.twitter.conversions.time._ | |
import com.twitter.finagle.{ThriftMux} | |
import com.twitter.finagle.util.DefaultTimer | |
import com.twitter.util.{Await, Future} | |
import net.gutefrage.temperature.thrift._r | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.gutefrage | |
import com.twitter.finagle._ | |
import com.twitter.finagle.http.service.HttpResponseClassifier | |
import com.twitter.server.TwitterServer | |
import com.twitter.util.Await | |
import io.finch._ | |
import io.finch.circe._ | |
import io.circe.generic.auto._ | |
import net.gutefrage.temperature.thrift._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.gutefrage | |
import com.twitter.finagle.Dtab | |
/** | |
* Holds different delegation tables | |
*/ | |
object Dtabs { | |
def init(): Unit = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import flaggable type class | |
import Env._ | |
// start a service in an environment with | |
// --env prod | |
val env = flag[Env]("env", Env.Local, "environment this server runs") | |
val port = flag[Int]("port", 8080, "port this server should use") | |
val server = ThriftMux.server | |
.withLabel("temperature-service") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.gutefrage.context | |
import com.twitter.finagle.context.Contexts | |
import com.twitter.finagle.util.ByteArrays | |
import com.twitter.io.Buf | |
import com.twitter.util.{Return, Throw, Try} | |
case class UserContext(userId: Long) | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// user endpoint which sets a UserContext | |
val userMean: Endpoint[MeanForUser] = get("weather" / "mean" / "user" :: long) { userId: Long => | |
val userContext = UserContext(userId) | |
Contexts.broadcast.let(UserContext, userContext) { | |
client.mean().map(mean => Ok(MeanForUser(mean, userId))) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node { | |
stage('Git') { | |
git 'https://github.com/muuki88/activator-play-cluster-sample.git' | |
} | |
stage('Build') { | |
def builds = [:] | |
builds['scala'] = { | |
// assumes you have the sbt plugin installed and created an sbt installation named 'sbt-0.13.13' | |
sh "${tool name: 'sbt-0.13.13', type: 'org.jvnet.hudson.plugins.SbtPluginBuilder$SbtInstallation'}/bin/sbt compile test" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface UserStorage { | |
/** set a value for a specific key */ | |
set(key: string, value: string): void; | |
/** get the value for a specific key. If not present return null*/ | |
get(key: string): string | null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type UserStorageKey = 'setting1' | 'setting2' | 'setting3'; | |
interface UserStorage { | |
/** set a value for a specific key */ | |
set(key: UserStorageKey, value: string): void; | |
/** get the value for a specific key. If not present return null*/ | |
get(key: UserStorageKey): string | null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type KeyValueStorage = { | |
'setting1': boolean; | |
'setting2': string; | |
'setting3': number; | |
}; | |
/** all possible keys for the key-value storage */ | |
type KeyValueStorageKey = keyof KeyValueStorage; | |
interface UserStorage { |