本文整理汇总了Scala中com.lightbend.lagom.scaladsl.api.Service类的典型用法代码示例。如果您正苦于以下问题:Scala Service类的具体用法?Scala Service怎么用?Scala Service使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Service类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: Lagomneo4jsampleService
//设置package包名称以及导入依赖的类
package com.inocybe.lagomneo4jsample.api
import akka.{Done, NotUsed}
import com.inocybe.lagomneo4jsample.model.RecipeOut
import com.lightbend.lagom.scaladsl.api.transport.Method
import com.lightbend.lagom.scaladsl.api.{Service, ServiceCall}
object Lagomneo4jsampleService {
val entityId: String = "my-entity"
}
trait Lagomneo4jsampleService extends Service {
def getRecipe(id: String): ServiceCall[NotUsed, RecipeOut]
override final def descriptor = {
import Service._
// @formatter:off
named("recipe-service").withCalls(
restCall(Method.POST, "/recipes/", this.addRecipe),
restCall(Method.GET, "/recipes/:id", getRecipe _)
).withAutoAcl(true)
// @formatter:on
}
}
示例2: useGreeting
//设置package包名称以及导入依赖的类
package sample.helloworld.api
import akka.{Done, NotUsed}
import com.lightbend.lagom.scaladsl.api.broker.Topic
import com.lightbend.lagom.scaladsl.api.{Service, ServiceCall}
import sample.helloworld.api.model.GreetingMessage
def useGreeting(id: String): ServiceCall[GreetingMessage, Done]
override final def descriptor = {
import Service._
// @formatter:off
named("hello").withCalls(
pathCall("/api/hello/:id", hello _),
pathCall("/api/hello/:id", useGreeting _)
).withTopics(
topic(HelloService.TOPIC_NAME, greetingsTopic)
).withAutoAcl(true)
// @formatter:on
}
// The topic handle
def greetingsTopic(): Topic[GreetingMessage]
}
object HelloService {
val TOPIC_NAME = "wordCount"
}
示例3: descriptor
//设置package包名称以及导入依赖的类
package sample.helloworldconsumer.api
import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.{Service, ServiceCall}
import com.lightbend.lagom.scaladsl.api.transport.Method
import play.api.libs.json.{Format, Json}
trait HelloConsumerService extends Service {
override def descriptor = {
import Service._
named("wordCounts").withCalls(
restCall(Method.GET, "/api/wordcount", findTopHundredWordCounts _),
restCall(Method.GET, "/api/foo", foo)
).withAutoAcl(true)
}
def findTopHundredWordCounts(): ServiceCall[NotUsed, Map[String, Int]]
def foo(): ServiceCall[NotUsed, String]
case class WordDetails(word: String, count: String)
object WordDetails {
implicit val format: Format[WordDetails] = Json.format
}
}
示例4: createAccount
//设置package包名称以及导入依赖的类
package org.ioreskovic.greatmaterialcontinuum.api
import akka.{Done, NotUsed}
import com.lightbend.lagom.scaladsl.api.transport.Method
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
trait AccountService extends Service {
def createAccount(): ServiceCall[Account, Done]
def deleteAccount(username: String): ServiceCall[NotUsed, Done]
def activateAccount(username: String): ServiceCall[NotUsed, Done]
def deactivateAccount(username: String): ServiceCall[NotUsed, Done]
def getAccount(username: String): ServiceCall[NotUsed, Account]
override final def descriptor: Descriptor = {
import Service._
// @formatter:off
named("accounts")
.withCalls(
restCall(Method.POST, "/api/accounts/", createAccount _),
restCall(Method.DELETE, "/api/accounts/:username", deleteAccount _),
restCall(Method.GET, "/api/accounts/:username/activation", activateAccount _),
restCall(Method.GET, "/api/accounts/:username/deactivation", deactivateAccount _),
restCall(Method.GET, "/api/accounts/:username", getAccount _)
)
.withAutoAcl(true)
// @formatter:on
}
}
示例5: createPlayer
//设置package包名称以及导入依赖的类
package com.chriswk.gameranker.player.api
import java.util.UUID
import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.{Service, ServiceCall}
import play.api.libs.json.{Format, Json}
trait PlayerService extends Service {
def createPlayer: ServiceCall[CreatePlayer, Player]
def getPlayer(playerId: UUID): ServiceCall[NotUsed, Player]
def getPlayers: ServiceCall[NotUsed, Seq[Player]]
override def descriptor = {
import Service._
named("player").withCalls(
pathCall("/api/player", createPlayer),
pathCall("/api/player/:id", getPlayer _),
pathCall("/api/player", getPlayers)
)
}
}
case class Player(id: UUID, name: String)
object Player {
implicit val format: Format[Player] = Json.format
}
case class CreatePlayer(name: String)
object CreatePlayer {
implicit val format: Format[CreatePlayer] = Json.format
}
示例6: CollectSSHService
//设置package包名称以及导入依赖的类
package org.wex.cmsfs.collect.ssh.api
import akka.Done
import com.lightbend.lagom.scaladsl.api.transport.Method
import com.lightbend.lagom.scaladsl.api.{Service, ServiceCall}
import org.wex.cmsfs.common.`object`.CoreMonitorDetailForSsh
object CollectSSHService {
val SERVICE_NAME = "collect-ssh"
}
trait CollectSSHService extends Service {
def pushCollectItem: ServiceCall[CoreMonitorDetailForSsh, Done]
override final def descriptor = {
import Service._
import CollectSSHService._
named(SERVICE_NAME).withCalls(
restCall(Method.POST, "/v1/collect", pushCollectItem)
)
}
}
示例7: NotificationService
//设置package包名称以及导入依赖的类
package org.wex.cmsfs.notification.impl
import com.lightbend.lagom.scaladsl.api.{CircuitBreaker, Service, ServiceCall}
object NotificationService {
val SERVICE_NAME = "notification"
}
trait NotificationService extends Service {
def pushNotificationItem: ServiceCall[String, String]
override final def descriptor = {
import NotificationService._
import Service._
named(SERVICE_NAME).withCalls(
pathCall("/mns-web/services/rest/msgNotify", pushNotificationItem)
.withCircuitBreaker(CircuitBreaker.identifiedBy("alarm-circuitbreaker"))
)
}
}
示例8: ElasticsearchService
//设置package包名称以及导入依赖的类
package org.wex.cmsfs.elasticsearch.api
import akka.Done
import com.lightbend.lagom.scaladsl.api.{CircuitBreaker, Service, ServiceCall}
import com.lightbend.lagom.scaladsl.api.transport.Method
object ElasticsearchService {
val SERVICE_NAME = "elastic-search"
}
trait ElasticsearchService extends Service {
def pushElasticsearchItem(_index: String, _type: String): ServiceCall[String, Done]
override final def descriptor = {
import ElasticsearchService._
import Service._
named(SERVICE_NAME).withCalls(
restCall(Method.POST, "/:_index/:_type", pushElasticsearchItem _)
.withCircuitBreaker(CircuitBreaker.identifiedBy("elasticsearch-circuitbreaker"))
)
}
}
示例9: FormatAnalyzeService
//设置package包名称以及导入依赖的类
package org.wex.cmsfs.format.analyze.api
import akka.Done
import com.lightbend.lagom.scaladsl.api.{Service, ServiceCall}
object FormatAnalyzeService {
val SERVICE_NAME = "format-analyze"
}
trait FormatAnalyzeService extends Service {
def pushFormatAnalyze: ServiceCall[FormatAnalyzeItem, Done]
override final def descriptor = {
import FormatAnalyzeService._
import Service._
named(SERVICE_NAME).withCalls(
pathCall("/v1/format/analyze", pushFormatAnalyze)
)
}
}
示例10: MonitorService
//设置package包名称以及导入依赖的类
package ogr.wex.cmsfs.monitor.api
import akka.{Done, NotUsed}
import com.lightbend.lagom.scaladsl.api.transport.Method
import com.lightbend.lagom.scaladsl.api.{Service, ServiceCall}
import org.wex.cmsfs.config.api.CoreMonitorStatus
object MonitorService {
val SERVICE_NAME = "monitor"
}
trait MonitorService extends Service {
def getMonitorStatus: ServiceCall[NotUsed, Seq[CoreMonitorStatus]]
override final def descriptor = {
import Service._
import MonitorService._
named(SERVICE_NAME).withCalls(
restCall(Method.GET, "/v1/monitor/statuses", getMonitorStatus)
)
}
}
示例11: FormatAlarmService
//设置package包名称以及导入依赖的类
package org.wex.cmsfs.format.alarm.api
import akka.Done
import com.lightbend.lagom.scaladsl.api.{Service, ServiceCall}
object FormatAlarmService {
val SERVICE_NAME = "format-alarm"
}
trait FormatAlarmService extends Service {
def pushFormatAlarm: ServiceCall[FormatAlarmItem, Done]
override final def descriptor = {
import FormatAlarmService._
import Service._
named(SERVICE_NAME).withCalls(
pathCall("/v1/format/alarm", pushFormatAlarm)
)
}
}
示例12: CollectJDBCService
//设置package包名称以及导入依赖的类
package org.wex.cmsfs.collect.jdbc.api
import akka.Done
import com.lightbend.lagom.scaladsl.api.transport.Method
import com.lightbend.lagom.scaladsl.api.{Service, ServiceCall}
import org.wex.cmsfs.common.`object`.CoreMonitorDetailForJdbc
object CollectJDBCService {
val SERVICE_NAME = "collect-jdbc"
}
trait CollectJDBCService extends Service {
def pushCollectItem: ServiceCall[CoreMonitorDetailForJdbc, Done]
override final def descriptor = {
import Service._
named(CollectJDBCService.SERVICE_NAME).withCalls(
restCall(Method.POST, "/v1/collect", pushCollectItem)
)
}
}
示例13: Item
//设置package包名称以及导入依赖的类
package demo.api.basket
import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.broker.Topic
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import com.lightbend.lagom.scaladsl.api.transport._
import demo.api.basket.ExtraTransportExceptions.CustomExceptionSerializer
import play.api.Environment
import play.api.libs.json.{Format, Json}
case class Item(name: String, price: Int)
object Item {
implicit val itemFormat: Format[Item] = Json.format
}
case class Basket(items: Seq[Item], total: Int)
object Basket {
implicit val basketFormat: Format[Basket] = Json.format
}
case class OrderPlaced(basketId: String, basket: Basket)
object OrderPlaced {
implicit val orderPlacedFormat: Format[OrderPlaced] = Json.format
}
trait BasketService extends Service {
def getBasket(basketId: String): ServiceCall[NotUsed, Basket]
def getTotal(basketId: String): ServiceCall[NotUsed, Int]
def addItem(basketId: String): ServiceCall[Item, NotUsed]
def clearAll(basketId: String): ServiceCall[NotUsed, NotUsed]
def placeOrder(basketId: String): ServiceCall[NotUsed, NotUsed]
def placedOrders: Topic[OrderPlaced]
override def descriptor: Descriptor = {
import Method._
import Service._
named("basket").withCalls(
restCall(GET, "/basket/:basketId", getBasket _),
restCall(GET, "/basket/:basketId/total", getTotal _),
restCall(POST, "/basket/:basketId/items", addItem _),
restCall(DELETE, "/basket/:basketId/items", clearAll _),
restCall(POST, "/basket/:basketId/order", placeOrder _)
).withTopics(
topic("placed-orders", placedOrders)
).withExceptionSerializer(new CustomExceptionSerializer(Environment.simple()))
}
}
示例14: Item
//设置package包名称以及导入依赖的类
package demo.api.basket
import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.broker.Topic
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import com.lightbend.lagom.scaladsl.api.transport._
import play.api.libs.json.{Format, Json}
case class Item(name: String, price: Int)
object Item {
implicit val itemFormat: Format[Item] = Json.format
}
case class Basket(items: Seq[Item], total: Int)
object Basket {
implicit val basketFormat: Format[Basket] = Json.format
}
case class OrderPlaced(basketId: String, basket: Basket)
object OrderPlaced {
implicit val orderPlacedFormat: Format[OrderPlaced] = Json.format
}
trait BasketService extends Service {
def getBasket(basketId: String): ServiceCall[NotUsed, Basket]
def getTotal(basketId: String): ServiceCall[NotUsed, Int]
def addItem(basketId: String): ServiceCall[Item, NotUsed]
def clearAll(basketId: String): ServiceCall[NotUsed, NotUsed]
def placeOrder(basketId: String): ServiceCall[NotUsed, NotUsed]
def placedOrders: Topic[OrderPlaced]
override def descriptor: Descriptor = {
import Method._
import Service._
named("basket").withCalls(
restCall(GET, "/basket/:basketId", getBasket _),
restCall(GET, "/basket/:basketId/total", getTotal _),
restCall(POST, "/basket/:basketId/items", addItem _),
restCall(DELETE, "/basket/:basketId/items", clearAll _),
restCall(POST, "/basket/:basketId/order", placeOrder _)
).withTopics(
topic("placed-orders", placedOrders)
)
}
}
示例15: Item
//设置package包名称以及导入依赖的类
package demo.api.basket
import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import com.lightbend.lagom.scaladsl.api.transport._
import play.api.libs.json.{Format, Json}
case class Item(name: String, price: Int)
object Item {
implicit val itemFormat: Format[Item] = Json.format
}
case class Basket(items: Seq[Item], total: Int)
object Basket {
implicit val basketFormat: Format[Basket] = Json.format
}
trait BasketService extends Service {
def getBasket(basketId: String): ServiceCall[NotUsed, Basket]
def getTotal(basketId: String): ServiceCall[NotUsed, Int]
def addItem(basketId: String): ServiceCall[Item, NotUsed]
override def descriptor: Descriptor = {
import Method._
import Service._
named("basket").withCalls(
restCall(GET, "/basket/:basketId", getBasket _),
restCall(GET, "/basket/:basketId/total", getTotal _),
restCall(POST, "/basket/:basketId/items", addItem _)
)
}
}