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

Scala wire类代码示例

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

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



在下文中一共展示了wire类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: OrderApplication

//设置package包名称以及导入依赖的类
package demo.impl.order

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.broker.kafka.LagomKafkaComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import com.lightbend.lagom.scaladsl.server._
import com.softwaremill.macwire.wire
import demo.api.basket.BasketService
import demo.api.order.OrderService
import play.api.libs.ws.ahc.AhcWSComponents

import scala.collection.immutable.Seq

abstract class OrderApplication(ctx: LagomApplicationContext) extends LagomApplication(ctx)
  with AhcWSComponents
  with CassandraPersistenceComponents
  with LagomKafkaComponents {
  override def lagomServer: LagomServer = LagomServer.forServices {
    bindService[OrderService].to(wire[OrderServiceImpl])
  }

  lazy val basketService: BasketService = serviceClient.implement[BasketService]

  persistentEntityRegistry.register(wire[Order])

  wire[BasketServiceSubscriber]
}

class OrderApplicationLoader extends LagomApplicationLoader {
  override def loadDevMode(context: LagomApplicationContext): LagomApplication = {
    new OrderApplication(context) with LagomDevModeComponents {
      override def jsonSerializerRegistry: JsonSerializerRegistry = OrderSerializerRegistry
    }
  }

  override def load(context: LagomApplicationContext): LagomApplication = {
    new OrderApplication(context) {
      override def serviceLocator: ServiceLocator = NoServiceLocator
      override def jsonSerializerRegistry: JsonSerializerRegistry = OrderSerializerRegistry
    }
  }
}

object OrderSerializerRegistry extends JsonSerializerRegistry {
  import OrderEntityFormats._
  override def serializers: Seq[JsonSerializer[_]] = {
    Seq(JsonSerializer[OrderInitialized],
      JsonSerializer[OrderState],
      JsonSerializer[CreateOrder],
      JsonSerializer[GetOrder.type],
      JsonSerializer[OrderItems])
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:57,代码来源:OrderApplication.scala


示例2: HelloWorldServiceLoader

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

import com.lightbend.lagom.scaladsl.server.{LagomApplication, LagomApplicationContext, LagomApplicationLoader, LagomServer}
import com.softwaremill.macwire.wire
import me.alexray.lagom.kube.client.LagomKubeModeComponents
import me.alexray.helloWorldService.api.HelloWorldService
import play.api.libs.ws.ahc.AhcWSComponents

class HelloWorldServiceLoader extends LagomApplicationLoader {

  override def load(context: LagomApplicationContext): LagomApplication =
    new HelloWorldServiceApplication(context) with LagomKubeModeComponents

  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new HelloWorldServiceApplication(context) with LagomKubeModeComponents

  override def describeServices = List(
    readDescriptor[HelloWorldService]
  )
}

abstract class HelloWorldServiceApplication(context: LagomApplicationContext)
  extends LagomApplication(context) with AhcWSComponents
{
  // Bind the service that this server provides
  override lazy val lagomServer: LagomServer = serverFor[HelloWorldService](wire[HelloWorldServiceImpl])

} 
开发者ID:AlexanderRay,项目名称:lagom-on-kube,代码行数:29,代码来源:HelloWorldServiceLoader.scala


示例3: createActionBuilders

//设置package包名称以及导入依赖的类
package authentication

import authentication.deadbolt.config.{DeadboltHandlerCache, OAuthDeadboltHandler}
import authentication.oauth2.{AccessTokenRepo, AuthenticationConfig, OAuth2Controller, PlayWithFoodAuthorizationHandler}
import authentication.repositories.SecurityUserRepo
import authentication.services.api.{PasswordValidator, SecurityUserCreator, SecurityUserProvider}
import authentication.services.{PasswordValidatorImpl, SecurityUserService}
import be.objectify.deadbolt.scala.cache._
import be.objectify.deadbolt.scala.{ActionBuilders, DeadboltComponents}
import com.softwaremill.macwire.wire
import commons.CommonsComponents
import commons.config.WithControllerComponents
import play.api.mvc.PlayBodyParsers
import play.api.routing.Router
import play.api.routing.sird._

trait AuthenticationsComponents extends CommonsComponents with DeadboltComponents with WithControllerComponents{
  lazy val passwordValidator: PasswordValidator = wire[PasswordValidatorImpl]
  lazy val securityUserCreator: SecurityUserCreator = wire[SecurityUserService]
  lazy val securityUserProvider: SecurityUserProvider = wire[SecurityUserService]
  lazy val securityUserRepo: SecurityUserRepo = wire[SecurityUserRepo]

  lazy val oAuth2Controller: OAuth2Controller = wire[OAuth2Controller]

  lazy val playWithFoodAuthorizationHandler: PlayWithFoodAuthorizationHandler = wire[PlayWithFoodAuthorizationHandler]
  lazy val authenticationConfig: AuthenticationConfig = wire[AuthenticationConfig]
  lazy val accessTokenRepo: AccessTokenRepo = wire[AccessTokenRepo]


  override lazy val patternCache: PatternCache = wire[DefaultPatternCache]
  override lazy val compositeCache: CompositeCache = wire[DefaultCompositeCache]
  override lazy val handlers: HandlerCache = wire[DeadboltHandlerCache]
  lazy val oAuthDeadboltHandler: OAuthDeadboltHandler = wire[OAuthDeadboltHandler]

  protected def createActionBuilders: PlayBodyParsers => ActionBuilders = parsers => actionBuilders(deadboltActions(parsers))

  val authenticationRoutes: Router.Routes = {
    case POST(p"/oauth/accessToken") => oAuth2Controller.accessToken
  }
} 
开发者ID:Dasiu,项目名称:play-framework-scala-example-project,代码行数:41,代码来源:AuthenticationsComponents.scala


示例4:

//设置package包名称以及导入依赖的类
package users

import authentication.AuthenticationsComponents
import com.softwaremill.macwire.wire
import commons.config.WithControllerComponents
import play.api.routing.Router
import play.api.routing.sird._
import users.controllers.UserController
import users.repositories.UserRepo
import users.services.api.{UserCreator, UserProvider}
import users.services.{UserCreatorImpl, UserProviderImpl, UserRegistrationService, UserRegistrationValidator}

trait UsersComponents extends AuthenticationsComponents with WithControllerComponents {
  lazy val userController: UserController = wire[UserController]
  lazy val userRepo: UserRepo = wire[UserRepo]
  lazy val userCreator: UserCreator = wire[UserCreatorImpl]
  lazy val userProvider: UserProvider = wire[UserProviderImpl]
  lazy val userRegistrationService: UserRegistrationService = wire[UserRegistrationService]
  lazy val userRegistrationValidator: UserRegistrationValidator = wire[UserRegistrationValidator]

  val userRoutes: Router.Routes = {
    case GET(p"/users") => userController.all
    case GET(p"/users/login/$login") => userController.byLogin(login)
    case POST(p"/users/register") => userController.register
  }
} 
开发者ID:Dasiu,项目名称:play-framework-scala-example-project,代码行数:27,代码来源:UsersComponents.scala


示例5: ComputationFollowedByAsyncPublishing

//设置package包名称以及导入依赖的类
package org.zalando.benchmarks

import java.util.concurrent.TimeUnit

import akka.actor._
import com.softwaremill.macwire.wire
import org.openjdk.jmh.annotations._

import scala.concurrent.duration._
import scala.util.Random

object ComputationFollowedByAsyncPublishing {
  implicit val system = ActorSystem()

  val publishDuration = 15 millis
  val numTasks = 20000
  val numTokensToConsume = 5000000L // eats about 9-10 ms on my box

  val actors   = wire[Actors]
  val futures  = wire[Futures]
  val blocking = wire[Blocking]
  val streams  = wire[Streams]
  val rx       = wire[RxScala]

  def printResult(rs: Seq[PublishResult]): Unit = println(rs map computeResult sum)

  def computeResult(r: PublishResult): Int =
    r.result.result + r.result.job.payload(Random.nextInt(r.result.job.payload length))

  def numWorkers(coreFactor: Int): Int = Runtime.getRuntime.availableProcessors * coreFactor
}

@BenchmarkMode(Array(Mode.AverageTime))
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
class ComputationFollowedByAsyncPublishing {
  import ComputationFollowedByAsyncPublishing._

  @Benchmark def bmActors():          Unit =   actors benchmark  1          // <= 109 threads ("Live peak" in JVisualVM)
  @Benchmark def bmParallelFutures(): Unit =  futures benchmark  1          // <=  44 threads ("Live peak" in JVisualVM)
  @Benchmark def bmBlocking():        Unit = blocking benchmark 64          // <= 549 threads ("Live peak" in JVisualVM)
  @Benchmark def bmStreams():         Unit =  streams benchmark  1          // <=  52 threads ("Live peak" in JVisualVM)

//@Benchmark def bmRxScala():         Unit =       rx benchmark             // blows up with OutOfMemoryError :(

  @TearDown def tearDown(): Unit = system.terminate()
} 
开发者ID:narayana-glassbeam,项目名称:scala-concurrency-playground,代码行数:48,代码来源:ComputationFollowedByAsyncPublishing.scala


示例6: executionContext

//设置package包名称以及导入依赖的类
package modules

import com.softwaremill.macwire.wire
import io.getquill.{PostgresAsyncContext, SnakeCase}
import services._

import scala.concurrent.ExecutionContext


trait DatabaseModule {
  // quill
  implicit def executionContext: ExecutionContext
  // database
  lazy val dbCtx = new PostgresAsyncContext[SnakeCase]("ctx")
  lazy val universityService = wire[UniversityService]
  lazy val facultyService = wire[FacultyService]
  lazy val departmentService = wire[DepartmentService]
  lazy val userService = wire[UserService]
  lazy val passwordInfoService = wire[PasswordInfoService]
  lazy val employeeService = wire[EmployeeService]
  lazy val studentService = wire[StudentService]
} 
开发者ID:iriddhi,项目名称:mis,代码行数:23,代码来源:DatabaseModule.scala


示例7: NotificationsApp

//设置package包名称以及导入依赖的类
package it.wknd.reactive.backend

import akka.actor.{ActorSystem, Props}
import akka.http.scaladsl.Http
import akka.http.scaladsl.Http.ServerBinding
import akka.stream.ActorMaterializer
import akka.stream.actor.ActorPublisher
import akka.stream.scaladsl.{RunnableGraph, Sink, Source}
import com.softwaremill.macwire.wire
import com.typesafe.config.ConfigFactory
import it.wknd.reactive.backend.flow.EventGraph
import it.wknd.reactive.backend.model.{HealthNotification, HeartRate, Step}
import it.wknd.reactive.backend.source.{HrActorSource, SourceProvider, StepActorSource}

import scala.concurrent.Future

object NotificationsApp extends App {

  implicit val config = ConfigFactory.load()
  implicit val actorSystem = ActorSystem("hr-backend")
  implicit val ec = actorSystem.dispatcher
  implicit val materializer = ActorMaterializer()

  lazy val sourceProvider = wire[SourceProvider]

  val hrActor = actorSystem.actorOf(Props[HrActorSource])
  val hrPub = ActorPublisher[HeartRate](hrActor)

  val stepActor = actorSystem.actorOf(Props[StepActorSource])
  val stepPub = ActorPublisher[Step](stepActor)

  RunnableGraph fromGraph {
    EventGraph(
      stepSource = Source.fromPublisher(stepPub),
      hrSource = Source.fromPublisher(hrPub),
      sink = Sink.actorSubscriber[HealthNotification](Props[NotifierActor]))
  } run()

  val bindingFuture: Future[ServerBinding] =
    Http().bindAndHandle(sourceProvider.routes(hrActor = hrActor, stepActor = stepActor), "localhost", 2525)
} 
开发者ID:VlasShatokhin,项目名称:it-wknd-streams,代码行数:42,代码来源:NotificationsApp.scala


示例8: TripLoader

//设置package包名称以及导入依赖的类
package com.packt.chapter11.trip.impl

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.server.{LagomApplication, LagomApplicationContext, LagomApplicationLoader, LagomServer}
import com.packt.chapter11.trip.api.TripService
import com.softwaremill.macwire.wire
import play.api.libs.ws.ahc.AhcWSComponents

class TripLoader extends LagomApplicationLoader {

  override def load(context: LagomApplicationContext): LagomApplication =
    new TripApplication(context) {
      override def serviceLocator: ServiceLocator = NoServiceLocator
    }

  override def loadDevMode(context: LagomApplicationContext): LagomApplication = {
    new TripApplication(context) with LagomDevModeComponents
  }

  override def describeServices = List(
    readDescriptor[TripService]
  )
}

abstract class TripApplication(context: LagomApplicationContext)
  extends LagomApplication(context)
    with CassandraPersistenceComponents
    with AhcWSComponents {

  // Bind the services that this server provides
  override lazy val lagomServer = LagomServer.forServices(
    bindService[TripService].to(wire[TripServiceImpl])
  )

  // Register the JSON serializer registry
  override lazy val jsonSerializerRegistry = ClientSerializerRegistry

  // Register the AkkaCookbook persistent entity
  persistentEntityRegistry.register(wire[ClientEntity])
} 
开发者ID:PacktPublishing,项目名称:Akka-Cookbook,代码行数:44,代码来源:TripLoader.scala


示例9: CalculatorLoader

//设置package包名称以及导入依赖的类
package com.packt.chapter11.akka.impl

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.server.{LagomApplication, LagomApplicationContext, LagomApplicationLoader, LagomServer}
import com.packt.chapter11.akka.api.CalculatorService
import com.softwaremill.macwire.wire
import play.api.libs.ws.ahc.AhcWSComponents

class CalculatorLoader extends LagomApplicationLoader {
  override def load(context: LagomApplicationContext): LagomApplication =
    new CalculatorApplication(context) {
      override def serviceLocator: ServiceLocator = NoServiceLocator
    }

  override def loadDevMode(context: LagomApplicationContext): LagomApplication = {
    new CalculatorApplication(context) with LagomDevModeComponents
  }

  override def describeServices = List(
    readDescriptor[CalculatorService]
  )
}

abstract class CalculatorApplication(context: LagomApplicationContext)
  extends LagomApplication(context)
    with AhcWSComponents {

  // Bind the services that this server provides
  override lazy val lagomServer = LagomServer.forServices(
    bindService[CalculatorService].to(wire[CalculatorServiceImpl])
  )
} 
开发者ID:PacktPublishing,项目名称:Akka-Cookbook,代码行数:35,代码来源:CalculatorLoader.scala


示例10: ConsumerLoader

//设置package包名称以及导入依赖的类
package com.packt.chapter11.consumer.impl

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.server.{LagomApplication, LagomApplicationContext, LagomApplicationLoader, LagomServer}
import com.packt.chapter11.consumer.api.ConsumerService
import com.packt.chapter11.token.api.TokenService
import com.softwaremill.macwire.wire
import play.api.libs.ws.ahc.AhcWSComponents

class ConsumerLoader extends LagomApplicationLoader {
  override def load(context: LagomApplicationContext): LagomApplication =
    new ConsumerApplication(context) {
      override def serviceLocator: ServiceLocator = NoServiceLocator
    }

  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new ConsumerApplication(context) with LagomDevModeComponents

  override def describeServices = List(readDescriptor[ConsumerService])
}

abstract class ConsumerApplication(context: LagomApplicationContext)
  extends LagomApplication(context)
    with AhcWSComponents {

  // Bind the services that this server provides
  override lazy val lagomServer = LagomServer.forServices(
    bindService[ConsumerService].to(wire[ConsumerServiceImpl])
  )

  lazy val tokenService = serviceClient.implement[TokenService]
} 
开发者ID:PacktPublishing,项目名称:Akka-Cookbook,代码行数:35,代码来源:ConsumerLoader.scala


示例11: ec

//设置package包名称以及导入依赖的类
package dao

import akka.actor.ActorSystem
import models.{OrderPlaced, UserRecognized}
import play.api.BuiltInComponents

import scala.concurrent.ExecutionContext

trait DaoModule extends BuiltInComponents {

  import com.softwaremill.macwire.wire
  import com.softwaremill.tagging._

  implicit def ec: ExecutionContext =
    ExecutionContext.global
  implicit def sys: ActorSystem =
    actorSystem

  private def userTopic =
    "users".taggedWith[UserRecognized]
  private def orderTopic = "orders".taggedWith[OrderPlaced]

  lazy val orderDao: EventDao[OrderPlaced] =
    wire[KafkaDao[OrderPlaced]]
  lazy val userDao: EventDao[UserRecognized] =
    wire[KafkaDao[UserRecognized]]
} 
开发者ID:leanovate,项目名称:contoso-conference-manager,代码行数:28,代码来源:DaoModule.scala


示例12: initDbAggregation

//设置package包名称以及导入依赖的类
package loader

import com.softwaremill.macwire.wire
import model.sensor.impl.{LocationRepositorySql, SensorRepositorySql}
import play.api.BuiltInComponents
import play.api.libs.concurrent.Execution.Implicits._

import scala.concurrent.duration._
import scala.language.postfixOps


trait DaoConfig extends BuiltInComponents with ClockConfig with SqlH2Config {
  lazy val locationRepository: LocationRepositorySql = wire[LocationRepositorySql]
  lazy val sensorRepository: SensorRepositorySql = new SensorRepositorySql(locationRepository, clock)

  def initDbAggregation(): Unit = {
    actorSystem.scheduler.schedule(
      10 second,
      1 hour,
      new Runnable {
        override def run() = {
          sensorRepository.findAll().foreach(sensor => sensor.aggregateOldMeasurements())
        }
      }
    )
  }
} 
开发者ID:vavravl1,项目名称:home_center,代码行数:28,代码来源:DaoConfig.scala


示例13: initializeListeners

//设置package包名称以及导入依赖的类
package loader

import akka.actor.{ActorRef, Props}
import com.softwaremill.macwire.wire
import config.HomeControllerConfiguration
import model.actuator.impl.ActuatorRepositoryNaive
import mqtt.clown.BridgeListener
import mqtt.watering.{WateringCommander, WateringHelloListener, WateringListener}
import mqtt.{MqttConnector, MqttDispatchingListener, MqttListenerMessage, MqttRepeater}
import play.api.BuiltInComponents


trait MqttConfig extends BuiltInComponents with DaoConfig with ClockConfig {
  lazy val mqttDispatchingListener: MqttDispatchingListener = wire[MqttDispatchingListener]
  lazy val mqttConnector = new MqttConnector(
    HomeControllerConfiguration(
      mqttBrokerUrl = configuration.getString("home_center.mqtt.url").get,
      mqttClientId = configuration.getString("home_center.mqtt.clientId").get
    ),
    mqttDispatchingListener,
    actorSystem
  )
  lazy val wateringCommander = wire[WateringCommander]

  lazy val actuatorRepository: ActuatorRepositoryNaive = wire[ActuatorRepositoryNaive]

  lazy val wateringListener: ActorRef = actorSystem.actorOf(Props(wire[WateringListener]))
  lazy val wateringHelloListener: ActorRef = actorSystem.actorOf(Props(wire[WateringHelloListener]))
  lazy val bcBridgeListenerActor: ActorRef = actorSystem.actorOf(Props(wire[BridgeListener]))
  lazy val mqttRepeaterActor: ActorRef = actorSystem.actorOf(Props(
    new MqttRepeater(
      HomeControllerConfiguration(
        configuration.getString("home_center.mqtt_repeater.url").orNull,
        configuration.getString("home_center.mqtt_repeater.clientId").orNull
      ),
      actorSystem,
      mqttConnector
    )
  ))

  def initializeListeners(): Unit = {
    mqttConnector.reconnect.run()

    bcBridgeListenerActor ! MqttListenerMessage.Ping
    wateringListener ! MqttListenerMessage.Ping
    wateringHelloListener ! MqttListenerMessage.Ping
    mqttRepeaterActor ! MqttListenerMessage.Ping

    mqttDispatchingListener.addListener(bcBridgeListenerActor.path)
    mqttDispatchingListener.addListener(wateringListener.path)
    mqttDispatchingListener.addListener(wateringHelloListener.path)
    mqttDispatchingListener.addListener(mqttRepeaterActor.path)
  }
} 
开发者ID:vavravl1,项目名称:home_center,代码行数:55,代码来源:MqttConfig.scala


示例14: initWsQuerying

//设置package包名称以及导入依赖的类
package loader

import com.softwaremill.macwire.wire
import play.api.BuiltInComponents
import play.api.libs.concurrent.Execution.Implicits._
import play.api.libs.ws.ahc.AhcWSClient
import ws.WattmeterClient

import scala.concurrent.duration._
import scala.language.postfixOps


trait WsClientConfig extends BuiltInComponents with DaoConfig with ClockConfig {
  lazy val wsClient = AhcWSClient()
  lazy val wattmeterClient = wire[WattmeterClient]

  def initWsQuerying(): Unit = {
    actorSystem.scheduler.schedule(
      1 second,
      1 second,
      new Runnable {
        override def run() = {
          wattmeterClient.queryWattmeter()
        }
      }
    )
  }
} 
开发者ID:vavravl1,项目名称:home_center,代码行数:29,代码来源:WsClientConfig.scala


示例15: WateringListenerTest

//设置package包名称以及导入依赖的类
package mqtt.watering

import java.time.{Clock, Instant}

import akka.actor.{ActorSystem, Props}
import akka.testkit.TestActorRef
import com.softwaremill.macwire.wire
import model.sensor._
import model.sensor.impl.{LocationRepositorySql, LocationSql, SensorRepositorySql}
import mqtt.MqttListenerMessage.ConsumeMessage
import org.scalamock.scalatest.MockFactory
import org.scalatest.{Matchers, WordSpec}


class WateringListenerTest extends WordSpec with Matchers with MockFactory {
  "WateringListener" when {

    implicit val system = ActorSystem()
    val clock = mock[Clock]
    val instant = Instant.ofEpochSecond(22)
    (clock.instant _).expects().returning(instant).atLeastOnce()

    "receives the message" should {
      "store it in dao if the message is correct" in {
        val locationRepository = mock[LocationRepositorySql]
        val sensorRepository = mock[SensorRepositorySqlWithCtor]
        val listener = TestActorRef[WateringListener](Props(wire[WateringListener]))
        val sensor = mock[Sensor]
        val humidityPhenomenon = mock[MeasuredPhenomenon]
        val wateringPhenomenon = mock[MeasuredPhenomenon]
        val location = LocationSql("watering-ibiscus", "label")

        (locationRepository.findOrCreateLocation _).expects("watering-ibiscus").returning(location)
        (sensorRepository.findOrCreateSensor _).expects(location, "watering").returning(sensor)

        (sensor.findOrCreatePhenomenon _).expects( "humidity", "", IdentityMeasurementAggregationStrategy).returning(humidityPhenomenon)
        (sensor.addMeasurement _).expects(Measurement(86, Instant.ofEpochSecond(22)), humidityPhenomenon)

        (sensor.findOrCreatePhenomenon _).expects( "watering", "", BooleanMeasurementAggregationStrategy).returning(wateringPhenomenon)
        (sensor.addMeasurement _).expects(Measurement(10, Instant.ofEpochSecond(22)), wateringPhenomenon)

        val correctJson = """ {"ts":8119,"tm":{"hu":{"a":86,"bl":512,"md":1000,"bs":10,"pd":30},"wa":{"ip":true,"wp":20000,"wt":5000},"wlh":true}}"""
        listener ! ConsumeMessage("home/watering/ibisek/telemetry", correctJson)
      }
    }
  }

  class SensorRepositorySqlWithCtor extends SensorRepositorySql(null, null)
} 
开发者ID:vavravl1,项目名称:home_center,代码行数:50,代码来源:WateringListenerTest.scala


示例16: MicroService

//设置package包名称以及导入依赖的类
import java.net.InetSocketAddress

import com.softwaremill.macwire.wire
import com.twitter.finagle.builder.ServerBuilder
import com.twitter.finagle.http.Http
import processors.FakeReportProcessor

object MicroService extends App {
//  lazy val loginService = wire[AlwaysSuccessfulLoginService]
//  lazy val reportProcessor = wire[FakeReportProcessor]
  val loginService = new AlwaysSuccessfulLoginService()
  val reportProcessor = new FakeReportProcessor()
  val authenticationFilter = new AuthenticationFilter(loginService)
  val processReportHandler = new ProcessReportHandler(reportProcessor)
//  lazy val authenticationFilter: AuthenticationFilter = wire[AuthenticationFilter]
//  lazy val processReportHandler: ProcessReportHandler = wire[ProcessReportHandler]

  val serviceChain = authenticationFilter.andThen(processReportHandler)

  val socketAddress = new InetSocketAddress(9000)
  val server = ServerBuilder()
    .codec(Http())
    .bindTo(socketAddress)
    .name("HTTP endpoint")
    .build(serviceChain)

  println("microservice started")
} 
开发者ID:adilansari,项目名称:finagle-play-akka,代码行数:29,代码来源:MicroService.scala


示例17: executionContext

//设置package包名称以及导入依赖的类
package com.optrak.testakka.simple.impl

import com.lightbend.lagom.internal.client.CircuitBreakerMetricsProviderImpl
import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.server.{LagomApplication, LagomApplicationContext, LagomApplicationLoader, LagomServerComponents, _}
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import play.api.libs.ws.ahc.AhcWSComponents
import com.lightbend.lagom.scaladsl.broker.kafka.LagomKafkaComponents
import com.lightbend.lagom.scaladsl.client.LagomServiceClientComponents
import com.optrak.testakka.api.PersistentService
import com.optrak.testakka.simple.api.SimpleService
import com.softwaremill.macwire.{wire, _}

import scala.concurrent.ExecutionContext

trait SimpleServiceComponents extends LagomServerComponents
  with CassandraPersistenceComponents
  with LagomServiceClientComponents {
  implicit def executionContext: ExecutionContext

  implicit lazy val persistentService = serviceClient.implement[PersistentService]
  override lazy val lagomServer = serverFor[SimpleService](wire[SimpleServiceImpl])
  override lazy val jsonSerializerRegistry = SimpleServiceSerializerRegistry
}

class SimpleServiceLoader extends LagomApplicationLoader {
  override def load(context: LagomApplicationContext): LagomApplication =
    new SimpleServiceApplication(context)    {
      override def serviceLocator: ServiceLocator = NoServiceLocator
    }
  override def describeServices = List(readDescriptor[SimpleService]  )

  override def loadDevMode(context: LagomApplicationContext): LagomApplication = {
    new SimpleServiceApplication(context ) with LagomDevModeComponents
  }
}


abstract class SimpleServiceApplication(context: LagomApplicationContext)
  extends LagomApplication(context)
    with SimpleServiceComponents
    with CassandraPersistenceComponents
    with AhcWSComponents 
开发者ID:Optrak,项目名称:lagom-testbed,代码行数:46,代码来源:SimpleServiceLoader.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala Element类代码示例发布时间:2022-05-23
下一篇:
Scala Request类代码示例发布时间: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