• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala Service类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中com.lightbend.lagom.scaladsl.api.Service的典型用法代码示例。如果您正苦于以下问题:Scala Service类的具体用法?Scala Service怎么用?Scala Service使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Service类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
  }
} 
开发者ID:botekchristophe,项目名称:lagom-neo4j-sample,代码行数:26,代码来源:Lagomneo4jsampleService.scala


示例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"
} 
开发者ID:knoldus,项目名称:lagom-scala-wordcount.g8,代码行数:30,代码来源:HelloService.scala


示例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
  }
} 
开发者ID:knoldus,项目名称:lagom-scala-wordcount.g8,代码行数:29,代码来源:HelloConsumerService.scala


示例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
  }
} 
开发者ID:ioreskovic,项目名称:great-material-continuum,代码行数:34,代码来源:AccountService.scala


示例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
} 
开发者ID:chriswk,项目名称:gameranker,代码行数:37,代码来源:PlayerService.scala


示例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)
    )
  }
} 
开发者ID:shinhwagk,项目名称:cmsfs,代码行数:24,代码来源:CollectSSHService.scala


示例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"))
    )
  }
} 
开发者ID:shinhwagk,项目名称:cmsfs,代码行数:22,代码来源:NotificationService.scala


示例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"))
    )
  }
} 
开发者ID:shinhwagk,项目名称:cmsfs,代码行数:24,代码来源:ElasticsearchService.scala


示例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)
    )
  }
} 
开发者ID:shinhwagk,项目名称:cmsfs,代码行数:22,代码来源:FormatAnalyzeService.scala


示例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)
    )
  }
} 
开发者ID:shinhwagk,项目名称:cmsfs,代码行数:24,代码来源:MonitorService.scala


示例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)
    )
  }
} 
开发者ID:shinhwagk,项目名称:cmsfs,代码行数:22,代码来源:FormatAlarmService.scala


示例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)
    )
  }
} 
开发者ID:shinhwagk,项目名称:cmsfs,代码行数:23,代码来源:CollectJDBCService.scala


示例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()))
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:49,代码来源:BasketService.scala


示例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)
    )
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:47,代码来源:BasketService.scala


示例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 _)
    )
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:34,代码来源:BasketService.scala


示例16: 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 addItem(basketId: String): ServiceCall[Item, NotUsed]

  override def descriptor: Descriptor = {
    import Method._
    import Service._

    named("basket").withCalls(
      restCall(GET, "/basket/:basketId", getBasket _),
      restCall(POST, "/basket/:basketId/items", addItem _)
    )
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:32,代码来源:BasketService.scala


示例17: 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]
  def clearAll(basketId: String): ServiceCall[NotUsed, 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 _),
      restCall(DELETE, "/basket/:basketId/items", clearAll _)
    )
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:36,代码来源:BasketService.scala


示例18: sensorMapping

//设置package包名称以及导入依赖的类
package com.ss.mapping.api

import java.util.UUID

import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.transport.Method
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import play.api.libs.json.{Format, Json}

import scala.concurrent.Future


trait MappingService extends Service {

  def sensorMapping(nodeId: Long, sensorId: Int): ServiceCall[NotUsed, SensorMapping]
  def registerMapping(nodeId: Long, sensorId: Int): ServiceCall[SensorMapping, NotUsed]
  def unregisterMapping(nodeId: Long, sensorId: Int): ServiceCall[NotUsed, NotUsed]
  override final def descriptor: Descriptor = {
    import Service._
    named("mapping").withCalls(
      pathCall("/api/sensorMapping/nodes/:node/sensors/:sensor", sensorMapping _),
      pathCall("/api/sensorMapping/nodes/:node/sensors/:sensor", registerMapping _),
      restCall(Method.DELETE, "/api/sensorMapping/nodes/:node/sensors/:sensor", unregisterMapping _)
    ).withAutoAcl(true)
  }

}

case class GlobalSensorId(nodeId: Long, sensorId: Int)
case class SensorMapping(objectId: UUID, domain: String, metricName: String)
object GlobalSensorId {
  implicit val jsonFormat: Format[GlobalSensorId] = Json.format[GlobalSensorId]
}
object SensorMapping {
  implicit val jsonFormat: Format[SensorMapping] = Json.format[SensorMapping]
} 
开发者ID:ytaras,项目名称:iot_lagom_poc,代码行数:37,代码来源:MappingService.scala


示例19: query

//设置package包名称以及导入依赖的类
package me.alexray.wolfram.api

import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import me.alexray.lagom.kube.api.ServiceDescriptor

trait WolframService extends Service {

  val sd = ServiceDescriptor("wolfram", "v1")

  def query(q: String): ServiceCall[NotUsed, String]
  def simple(q: String): ServiceCall[NotUsed, Array[Byte]]

  override final def descriptor: Descriptor = {
    import Service._

    named(sd.name)
      .withCalls(
        pathCall(sd.versionedPath("query/:q"), query _),
        pathCall(sd.versionedPath("simple/:q"), simple _)
      ).withAutoAcl(true)
  }
} 
开发者ID:AlexanderRay,项目名称:lagom-on-kube,代码行数:24,代码来源:WolframService.scala


示例20: hello

//设置package包名称以及导入依赖的类
package me.alexray.helloWorldService.api

import akka.{Done, NotUsed}
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import me.alexray.lagom.kube.api.ServiceDescriptor

trait HelloWorldService extends Service {

  val sd = ServiceDescriptor("helloworldservice", "v1")

  def hello(): ServiceCall[NotUsed, List[String]]

  override final def descriptor: Descriptor = {
    import Service._
    // @formatter:off
    named(sd.name).withCalls(
      pathCall(sd.versionedPath("hello"), hello _)
    ).withAutoAcl(true)
    // @formatter:on
  }
} 
开发者ID:AlexanderRay,项目名称:lagom-on-kube,代码行数:22,代码来源:HelloWorldService.scala



注:本文中的com.lightbend.lagom.scaladsl.api.Service类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala LocalDateTime类代码示例发布时间:2022-05-23
下一篇:
Scala DoubleMatrix类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap