Kailuo Wang
kailuowang.github.io
Kai(luo) Wang @kailuowang
###
# summary: Get a user's tests and the groups he/she is in
# parameters:
# - name: time
# description: epoch millis for the time as of when
# responses:
# 200:
# description: A map of test ids to group names
# schema:
# $ref: '#/definitions/api.abtest.service.Protocol.GroupsResult'
###
GET /users/:userId/tests/groups abtest.MainController.getGroups(userId: Int, time: Long)
###
# summary: create a new a/b test
# parameters:
# - name: body
# schema:
# $ref: '#/definitions/api.abtest.service.Protocol.CreateTest'
# responses:
# 200:
# schema:
# $ref: '#/definitions/api.abtest.service.Protocol.TestCreated'
###
POST /tests poweramp.abtest.MainController.createTest()
package abtest
import ...
case class MainController(backend: ActorRef)(
implicit ...
) extends DistributedController {
handle(
"getGroups",
process[GetGroups]()
)(using(backend).
expect[GroupsResult] >>
respondJson(Ok))
handle(
"createTest",
process[CreateTest](
from(author = authenticatedUserName),
from(test = jsonBody[ABTest]))
)(using(backend).
expect[TestCreated] >>
respondJson(Ok))
}
package api.abtest.service
object Protocol {
case class GetGroups(
userId: ProfileId,
time: DateTime
)
case class GroupsResult(
groups: Map[TestId, GroupName]
)
case class CreateTest(
test: ABTest,
author: String
)
case class ABTest(
name: TestName,
start: DateTime,
end: DateTime,
statisticalTestType: StatisticalTestType,
groups: Vector[Group]
)
case class TestCreated(
test: ABtest
)
}
###
# summary: Get a user's tests and the groups he/she is in
# parameters:
# - name: time
# description: epoch millis for the time as of when
# responses:
# 200:
# description: A map of test ids to group names
# schema:
# $ref: '#/definitions/api.abtest.service.Protocol.GroupsResult'
###
GET /users/:userId/tests/groups abtest.MainController.getGroups(userId: Int, time: Long)
###
# summary: create a new a/b test
# parameters:
# - name: body
# schema:
# $ref: '#/definitions/api.abtest.service.Protocol.CreateTest'
# responses:
# 200:
# schema:
# $ref: '#/definitions/api.abtest.service.Protocol.TestCreated'
###
POST /tests poweramp.abtest.MainController.createTest()
Amit Patel
Joseph Price - @joprice
Kailuo Wang - @kailuowang
Laurent Vauthrin
Marcel Walden
Matt Fielder
William Ho
Adam Denenberg - @denen
James Roper - @jroper
Jim Powers - @corruptmemory
Konrad Malawski - @ktosopl
Miles Sabin - @milessabin
Patrik Nordwall - @patriknw
Rich Dougherty - @richdougherty
val getUser: Id => User
val getUser: Kleisli[
XorT[Future, Reason, ?], Id, User
]
case class User(name: Name, age: Age)
def validateUser: K[(AccountName, Password), Id]
def getUserName: K[Id, Name]
def getUserAge: K[Id, Age]
validateUser andThen getUserName
def getUser: K[Id, User] =
for {
name <- getUserName
age <- getUserAge
} yield User(name, age)
val gen = sequenceGeneric[User]
def getUser: K[Id, User] =
gen(
name = getUserName,
age = getUserAge
)
By Kailuo Wang
An overview of Poweramp, a microservice platform at iHeartRadio.