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

Scala ExtensionIdProvider类代码示例

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

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



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

示例1: SettingsImpl

//设置package包名称以及导入依赖的类
import akka.actor.{ExtendedActorSystem, ExtensionIdProvider, ExtensionId, Extension}
import com.typesafe.config._

class SettingsImpl(config: Config) extends Extension {

  object Http {
    lazy val interface = config.getString("http.interface")
    lazy val port = config.getInt("http.port")
  }
}

object Settings extends ExtensionId[SettingsImpl] with ExtensionIdProvider {

  override def lookup = Settings

  override def createExtension(system: ExtendedActorSystem) =
    new SettingsImpl(system.settings.config)
} 
开发者ID:devknutst,项目名称:watermarkAkka,代码行数:19,代码来源:Settings.scala


示例2: InfluxDbConfig

//设置package包名称以及导入依赖的类
package io.soheila.cms.services.metrics.influx

import akka.actor.{ ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider }
import com.typesafe.config.Config


class InfluxDbConfig(config: Config) extends Extension {
  val host: String = config.getString("influxDb.host")
  val port: Int = config.getInt("influxDb.port")
  val username: String = config.getString("influxDb.username")
  val password: String = config.getString("influxDb.password")
  val database: String = config.getString("influxDb.database")
}

object InfluxDbConfig extends ExtensionId[InfluxDbConfig] with ExtensionIdProvider {
  override def lookup() = InfluxDbConfig

  override def createExtension(system: ExtendedActorSystem): InfluxDbConfig =
    new InfluxDbConfig(system.settings.config)
} 
开发者ID:esfand-r,项目名称:soheila-cm,代码行数:21,代码来源:InfluxDbConfig.scala


示例3: trade

//设置package包名称以及导入依赖的类
package akka.performance.trading.domain

import java.util.concurrent.atomic.AtomicInteger

import akka.actor.{ ExtensionIdProvider, ExtensionId, Extension, ExtendedActorSystem, ActorSystem }

abstract trait TradeObserver {
  def trade(bid: Bid, ask: Ask)
}

trait TotalTradeObserver extends TradeObserver {
  def system: ActorSystem
  private lazy val counter: TotalTradeCounter = TotalTradeCounterExtension(system)
  override def trade(bid: Bid, ask: Ask) {
    counter.increment()
  }
}

trait NopTradeObserver extends TradeObserver {
  override def trade(bid: Bid, ask: Ask) {
  }
}

class TotalTradeCounter extends Extension {
  private val counter = new AtomicInteger

  def increment() = counter.incrementAndGet()
  def reset() {
    counter.set(0)
  }
  def count: Int = counter.get
}

object TotalTradeCounterExtension
  extends ExtensionId[TotalTradeCounter]
  with ExtensionIdProvider {
  override def lookup = TotalTradeCounterExtension
  override def createExtension(system: ExtendedActorSystem) = new TotalTradeCounter
} 
开发者ID:love1314sea,项目名称:akka-2.3.16,代码行数:40,代码来源:TradeObserver.scala


示例4: TransactorExtension

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

import akka.actor.{ ActorSystem, ExtensionId, ExtensionIdProvider, ExtendedActorSystem }
import akka.actor.Extension
import com.typesafe.config.Config
import akka.util.Timeout
import scala.concurrent.duration.Duration
import java.util.concurrent.TimeUnit.MILLISECONDS


@deprecated("akka.transactor will be removed", "2.3")
object TransactorExtension extends ExtensionId[TransactorSettings] with ExtensionIdProvider {
  override def get(system: ActorSystem): TransactorSettings = super.get(system)
  override def lookup: TransactorExtension.type = TransactorExtension
  override def createExtension(system: ExtendedActorSystem): TransactorSettings = new TransactorSettings(system.settings.config)
}

@deprecated("akka.transactor will be removed", "2.3")
class TransactorSettings(val config: Config) extends Extension {
  import config._
  val CoordinatedTimeout: Timeout = Timeout(Duration(getMilliseconds("akka.transactor.coordinated-timeout"), MILLISECONDS))
} 
开发者ID:love1314sea,项目名称:akka-2.3.16,代码行数:23,代码来源:TransactorExtension.scala


示例5: SettingsImpl

//设置package包名称以及导入依赖的类
package com.edu.chat

import akka.actor.{ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider}
import com.typesafe.config.Config

class SettingsImpl(config: Config) extends Extension {
  val dbUsername: String = config.getString("mongo.username")
  val dbPassword: Array[Char] = config.getString("mongo.password").toCharArray
  val dbHost: String = config.getString("mongo.host")
  val dbName: String = config.getString("mongo.db")
  val dbPort: Int = config.getInt("mongo.port")
  val webPort: Int = config.getInt("web.port")
  val staticContentPath: String = config.getString("web.staticContent")
  val clientIndexPath: String = config.getString("web.client")
}

object Settings extends ExtensionId[SettingsImpl] with ExtensionIdProvider {
  override def createExtension(system: ExtendedActorSystem): SettingsImpl = {
    new SettingsImpl(system.settings.config)
  }

  override def lookup(): ExtensionId[_ <: Extension] = Settings
} 
开发者ID:themirrortruth,项目名称:chat-akka,代码行数:24,代码来源:SettingsImpl.scala


示例6: UserConfigExtension

//设置package包名称以及导入依赖的类
package im.actor.server.userconfig

import akka.actor.{ ActorSystem, ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider }
import im.actor.api.rpc.configs.UpdateParameterChanged
import im.actor.hook.{ Hook2, Hook3, HooksStorage2, HooksStorage3 }
import im.actor.server.db.DbExtension
import im.actor.server.model.configs.Parameter
import im.actor.server.persist.configs.ParameterRepo
import im.actor.server.sequence.{ SeqState, SeqUpdatesExtension }
import im.actor.types._

import scala.concurrent.Future

object UserConfigExtension extends ExtensionId[UserConfigExtension] with ExtensionIdProvider {
  override def createExtension(system: ExtendedActorSystem) = new UserConfigExtension(system)

  override def lookup(): ExtensionId[_ <: Extension] = UserConfigExtension
}

final class UserConfigExtension(system: ActorSystem) extends Extension {

  import system.dispatcher

  private lazy val db = DbExtension(system).db
  private lazy val seqUpdExt = SeqUpdatesExtension(system)

  val hooks = new HooksStorage3[EditParameterHook, Any, UserId, String, Option[String]]()

  def fetchParameters(userId: Int): Future[Seq[(String, Option[String])]] = {
    for {
      params ? db.run(ParameterRepo.find(userId))
    } yield params.map(p ? p.key ? p.value)
  }

  def editParameter(userId: Int, authId: Long, rawKey: String, value: Option[String]): Future[SeqState] = {
    val key = rawKey.trim

    val update = UpdateParameterChanged(key, value)

    for {
      _ ? db.run(ParameterRepo.createOrUpdate(Parameter(userId, key, value)))
      seqState ? seqUpdExt.deliverClientUpdate(userId, authId, update)
    } yield {
      seqUpdExt.reloadSettings(userId)
      seqState
    }
  }
}

trait EditParameterHook extends Hook3[Any, UserId, String, Option[String]] 
开发者ID:wex5,项目名称:dangchat-server,代码行数:51,代码来源:UserConfigExtension.scala


示例7: Settings

//设置package包名称以及导入依赖的类
package com.mikemunhall.simpletwitterstats

import akka.actor.{ActorContext, ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider}
import com.typesafe.config.Config

object Settings extends ExtensionId[Settings] with ExtensionIdProvider {

  override def lookup = Settings
  override def createExtension(system: ExtendedActorSystem) = new Settings(system.settings.config, system)
  def apply(context: ActorContext): Settings = apply(context.system)
}

class Settings(config: Config, extendedSystem: ExtendedActorSystem) extends Extension {

  object API {
    object Http {
      val Port = config.getInt("simple-twitter-stats.api.http.port")
      val Interface = config.getString("simple-twitter-stats.api.http.interface")
    }
  }

  object Server {
    object Twitter {
      object Client {
        object OAuth {
          object Consumer {
            val key = config.getString("simple-twitter-stats.server.twitter.client.oauth.consumer.key")
            val secret = config.getString("simple-twitter-stats.server.twitter.client.oauth.consumer.secret")
          }
          object Access {
            val token = config.getString("simple-twitter-stats.server.twitter.client.oauth.access.token")
            val secret = config.getString("simple-twitter-stats.server.twitter.client.oauth.access.secret")
          }
        }
      }
    }
  }

} 
开发者ID:mmunhall,项目名称:simple-twitter-stats,代码行数:40,代码来源:Settings.scala


示例8: DbConnectionPoolExtension

//设置package包名称以及导入依赖的类
package org.guangwenz.akka.db.connpool

import java.sql.Connection
import java.util.UUID

import akka.actor.{ActorRef, ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider, Props}
import akka.pattern.ask
import akka.util.Timeout
import org.guangwenz.akka.db.connpool.ConnectionPool.{DbConnectionRetrieved, GetDbConnection, ShutdownConnectionPool}

import scala.concurrent.Await
import scala.concurrent.duration._


object DbConnectionPoolExtension extends ExtensionId[DbConnectionPoolExtension] with ExtensionIdProvider {
  override def createExtension(system: ExtendedActorSystem): DbConnectionPoolExtension = new DbConnectionPoolExtension(system)

  override def lookup(): ExtensionId[_ <: Extension] = DbConnectionPoolExtension
}

class DbConnectionPoolExtension(system: ExtendedActorSystem) extends Extension {

  private val connectionPool = system.actorOf(Props(new ConnectionPool()).withDispatcher("db-access-dispatcher"), "guangwenz-util-db")
  private implicit val timeout = Timeout(1.minutes)
  private val requests = Map()

  system.registerOnTermination {
    connectionPool ! ShutdownConnectionPool
  }

  def getConnection: Option[Connection] = {
    val future = connectionPool.ask(GetDbConnection(UUID.randomUUID().toString)).mapTo[DbConnectionRetrieved]
    try {
      Some(Await.result(future, 30.seconds).conn)
    } catch {
      case ex: Exception => None
    }
  }

  def connect(handler: (Either[Exception, Connection]) => Unit): Unit = {
    implicit val executor = system.dispatcher
    val future = connectionPool.ask(GetDbConnection(UUID.randomUUID().toString)).mapTo[DbConnectionRetrieved]
    try {
      handler(Right(Await.result(future, 30.seconds).conn))
    } catch {
      case exception: Exception =>
        handler(Left(exception))
    }
  }

  def getConnectionPoolActor: Option[ActorRef] = {
    Some(connectionPool)
  }
} 
开发者ID:zgwmike,项目名称:akka-db-connpool,代码行数:55,代码来源:DbConnectionPoolExtension.scala


示例9: KamonLogstash

//设置package包名称以及导入依赖的类
package com.codekeepersinc.kamonlogstash

import akka.actor.{ ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider }
import akka.event.Logging
import MetricShipper.ShipperConfig
import com.typesafe.config.Config
import kamon.Kamon
import kamon.util.ConfigTools.Syntax

import scala.collection.JavaConverters._
import scala.concurrent.duration.{ FiniteDuration, MILLISECONDS }

object KamonLogstash extends ExtensionId[KamonLogstashExtension] with ExtensionIdProvider {
  override def createExtension(system: ExtendedActorSystem): KamonLogstashExtension = new KamonLogstashExtension(system)

  override def lookup(): ExtensionId[_ <: Extension] = KamonLogstash
}

class KamonLogstashExtension(system: ExtendedActorSystem) extends Kamon.Extension {
  val log = Logging(system, classOf[KamonLogstashExtension])
  log.info("Starting the Kamon Logstash extension")

  private val metricsExtension = Kamon.metrics

  private val config = system.settings.config
  private val logstashConfig = config.getConfig("kamon.logstash")

  private val appName = logstashConfig.getString("appname")
  private val hostName = logstashConfig.getString("hostname")

  private val shipperConfig = ShipperConfig(
    address = logstashConfig.getString("address"),
    port = logstashConfig.getInt("port"),
    minBackoff = FiniteDuration(logstashConfig.getDuration("retry.minBackoff").toMillis, MILLISECONDS),
    maxBackoff = FiniteDuration(logstashConfig.getDuration("retry.maxBackoff").toMillis, MILLISECONDS),
    randomFactor = logstashConfig.getDouble("retry.randomFactor"),
    retryAutoReset = FiniteDuration(logstashConfig.getDuration("retry.retryAutoReset").toMillis, MILLISECONDS)
  )

  private val shipper = system.actorOf(MetricShipper.props(shipperConfig), "metric-shipper")
  private val logger = system.actorOf(MetricLogger.props(appName, hostName, shipper), "subscription-logger")

  private val subscriptions: Config = logstashConfig.getConfig("subscriptions")

  subscriptions.firstLevelKeys.foreach { subscriptionCategory =>
    subscriptions.getStringList(subscriptionCategory).asScala.foreach { pattern =>
      metricsExtension.subscribe(subscriptionCategory, pattern, logger, permanently = true)
    }
  }
} 
开发者ID:darienmt,项目名称:kamon-logstash,代码行数:51,代码来源:KamonLogstash.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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