当前位置: 首页>>代码示例>>Scala>>正文


Scala BasicAWSCredentials类代码示例

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


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

示例1: SNSClientModule

//设置package包名称以及导入依赖的类
package uk.ac.wellcome.finatra.modules

import javax.inject.Singleton

import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials}
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
import com.amazonaws.services.sns._
import com.google.inject.Provides
import com.twitter.inject.TwitterModule
import uk.ac.wellcome.models.aws.AWSConfig

object SNSClientModule extends TwitterModule {
  val snsEndpoint = flag[String](
    "aws.sns.endpoint",
    "",
    "Endpoint of AWS SNS. The region will be used if the enpoint is not provided")
  @Singleton
  @Provides
  def providesSNSClient(awsConfig: AWSConfig): AmazonSNS = {
    val standardSnsClient = AmazonSNSClientBuilder.standard
    if (snsEndpoint().isEmpty)
      standardSnsClient
        .withRegion(awsConfig.region)
        .build()
    else
      standardSnsClient
        .withCredentials(
          new AWSStaticCredentialsProvider(
            new BasicAWSCredentials(awsConfig.accessKey.get,
                                    awsConfig.secretKey.get)))
        .withEndpointConfiguration(
          new EndpointConfiguration(snsEndpoint(), awsConfig.region))
        .build()
  }
} 
开发者ID:wellcometrust,项目名称:platform-api,代码行数:36,代码来源:SNSClientModule.scala

示例2: SQSConsumer

//设置package包名称以及导入依赖的类
package com.hivehome.kafka.connect.sqs

import javax.jms.{JMSException, MessageConsumer, Session}

import com.amazon.sqs.javamessaging.SQSConnectionFactory
import com.amazonaws.auth.{AWSCredentialsProviderChain, BasicAWSCredentials, DefaultAWSCredentialsProviderChain}
import com.amazonaws.internal.StaticCredentialsProvider
import com.amazonaws.regions.{Region, Regions}

object SQSConsumer {
  def apply(conf: Conf): MessageConsumer = {
    val chain = buildCredentialsProviderChain(conf)
    createSQSConsumer(conf, chain)
  }

  @throws(classOf[JMSException])
  private def createSQSConsumer(conf: Conf, chain: AWSCredentialsProviderChain): MessageConsumer = {
    val region = Regions.fromName(conf.awsRegion)
    val connectionFactory = SQSConnectionFactory.builder
      .withRegion(Region.getRegion(region))
      .withAWSCredentialsProvider(chain)
      .build

    val connection = connectionFactory.createConnection
    val session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE)
    val queue = session.createQueue(conf.queueName.get)
    val consumer = session.createConsumer(queue)
    connection.start()
    consumer
  }

  private def buildCredentialsProviderChain(conf: Conf): AWSCredentialsProviderChain = {
    (conf.awsKey, conf.awsSecret) match {
      case (Some(key), Some(secret)) =>
        val credentials = new BasicAWSCredentials(key, secret)
        new AWSCredentialsProviderChain(new StaticCredentialsProvider(credentials), new DefaultAWSCredentialsProviderChain)
      case _ => new DefaultAWSCredentialsProviderChain
    }
  }
} 
开发者ID:ConnectedHomes,项目名称:sqs-kafka-connect,代码行数:41,代码来源:SQSConsumer.scala

示例3: createBucket

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

import java.io.InputStream

import com.amazonaws.auth.{ BasicAWSCredentials, DefaultAWSCredentialsProviderChain }
import com.amazonaws.services.s3.{ S3ClientOptions, AmazonS3Client }
import com.amazonaws.services.s3.model._

import scala.concurrent.{ Future, ExecutionContext }

trait S3Client {
  val s3ClientConfig: S3ClientConfig

  lazy val client: AmazonS3Client = {
    val client =
      if (s3ClientConfig.awsUseDefaultCredentialsProviderChain)
        new AmazonS3Client(new DefaultAWSCredentialsProviderChain).withRegion(s3ClientConfig.region)
      else
        new AmazonS3Client(new BasicAWSCredentials(s3ClientConfig.awsKey, s3ClientConfig.awsSecret))

    s3ClientConfig.endpoint.foreach { endpoint =>
      client.withEndpoint(endpoint)
      ()
    }
    client.setS3ClientOptions(new S3ClientOptions()
      .withPathStyleAccess(s3ClientConfig.options.pathStyleAccess)
      .withChunkedEncodingDisabled(s3ClientConfig.options.chunkedEncodingDisabled))
    client
  }

  def createBucket(bucketName: String)(implicit ec: ExecutionContext): Future[Bucket] = Future {
    client.createBucket(bucketName)
  }

  def deleteBucket(bucketName: String)(implicit ec: ExecutionContext): Future[Unit] = Future {
    client.deleteBucket(bucketName)
  }

  def putObject(bucketName: String, key: String, input: InputStream, metadata: ObjectMetadata)(implicit ec: ExecutionContext): Future[PutObjectResult] = Future {
    client.putObject(new PutObjectRequest(bucketName, key, input, metadata))
  }

  def getObject(bucketName: String, key: String)(implicit ec: ExecutionContext): Future[S3Object] = Future {
    client.getObject(new GetObjectRequest(bucketName, key))
  }

  def listObjects(request: ListObjectsRequest)(implicit ec: ExecutionContext): Future[ObjectListing] = Future {
    client.listObjects(request)
  }

  def deleteObject(bucketName: String, key: String)(implicit ec: ExecutionContext): Future[Unit] = Future {
    client.deleteObject(bucketName, key)
  }

  def deleteObjects(request: DeleteObjectsRequest)(implicit ec: ExecutionContext): Future[Unit] = Future {
    client.deleteObjects(request)
  }
} 
开发者ID:TanUkkii007,项目名称:akka-persistence-s3,代码行数:59,代码来源:S3Client.scala

示例4: SQS

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

import cats.data.Kleisli
import cats.~>
import com.amazonaws.auth.BasicAWSCredentials
import wookie.httpclient._
import wookie.result._
import wookie.service._
import wookie.signer._
import wookie.sqs.algebra.{ SQSIO, SQSOp }
import wookie.sqs.implicits._

import scala.concurrent.Future

case class SQS(props: Properties, client: HttpClient) extends Service {

  val endpoint = "https://sqs.amazonaws.com"

  val serviceName = "sqs"

  def credentials = new BasicAWSCredentials(
    props.accessKey,
    props.secretAccessKey
  )

  def run[A](op: SQSIO[A]): Future[A] = {
    val result = op foldMap sqsInterpreter

    result.run(Signer(endpoint, serviceName, credentials))
  }

  val sqsInterpreter = new (SQSOp ~> Result) {
    def apply[A](command: SQSOp[A]): Result[A] =
      Kleisli { signer: Signer ?
        client.exec(signer.sign(command.marshalledReq))(command.responseHandler, errorResponseHandler)
      }
  }

} 
开发者ID:pepegar,项目名称:wookie,代码行数:40,代码来源:S3.scala

示例5: S3

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

import cats.data.Kleisli
import cats.~>
import com.amazonaws.auth.BasicAWSCredentials
import wookie.httpclient._
import wookie.result._
import wookie.s3.algebra._
import wookie.service._
import wookie.signer._

import scala.concurrent.Future

import implicits._

case class S3(props: Properties, client: HttpClient) extends Service {

  val endpoint = "https://s3.amazonaws.com"

  val serviceName = "s3"

  def credentials = new BasicAWSCredentials(
    props.accessKey,
    props.secretAccessKey
  )

  def run[A](op: S3IO[A]): Future[A] = {
    val result = op foldMap s3Interpreter

    result.run(Signer(endpoint, serviceName, credentials))
  }

  val s3Interpreter = new (S3Op ~> Result) {
    def apply[A](command: S3Op[A]): Result[A] =
      Kleisli { signer: Signer ?
        client.exec(signer.sign(command.marshalledReq))(command.responseHandler, errorResponseHandler)
      }
  }

} 
开发者ID:pepegar,项目名称:wookie,代码行数:41,代码来源:S3.scala

示例6: DynamoDB

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

import cats.data.Kleisli
import cats.~>
import com.amazonaws.auth.BasicAWSCredentials
import wookie.dynamodb.algebra._
import wookie.httpclient._
import wookie.result._
import wookie.service._
import wookie.signer._

import scala.concurrent.Future
import scala.language._

import implicits._

case class DynamoDB(props: Properties, client: HttpClient) extends Service {

  def endpoint = "https://dynamodb.us-east-1.amazonaws.com"

  def serviceName = "dynamodb"

  def credentials = new BasicAWSCredentials(props.accessKey, props.secretAccessKey)

  def run[A](op: DynamoDBIO[A]): Future[A] = {
    val result = op foldMap dynamoDBInterpreter

    result.run(Signer(endpoint, serviceName, credentials))
  }

  val dynamoDBInterpreter = new (DynamoDBOp ~> Result) {
    def apply[A](command: DynamoDBOp[A]): Result[A] =
      Kleisli { signer: Signer ?
        client.exec(signer.sign(command.marshalledReq))(command.responseHandler, errorResponseHandler)
      }
  }
} 
开发者ID:pepegar,项目名称:wookie,代码行数:38,代码来源:DynamoDB.scala

示例7: Integration

//设置package包名称以及导入依赖的类
package akka.stream.alpakka.sqs.scaladsl

import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import com.amazonaws.auth.{AWSCredentialsProvider, AWSStaticCredentialsProvider, BasicAWSCredentials}
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
import com.amazonaws.services.sqs.{AmazonSQSAsync, AmazonSQSAsyncClientBuilder}
import org.elasticmq.rest.sqs.{SQSRestServer, SQSRestServerBuilder}
import org.scalatest.{BeforeAndAfterAll, Suite, Tag}

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

trait DefaultTestContext extends BeforeAndAfterAll { this: Suite =>

  lazy val sqsServer: SQSRestServer = SQSRestServerBuilder.withDynamicPort().start()
  lazy val sqsAddress = sqsServer.waitUntilStarted().localAddress
  lazy val sqsPort = sqsAddress.getPort
  lazy val sqsEndpoint: String = {
    s"http://${sqsAddress.getHostName}:$sqsPort"
  }

  object Integration extends Tag("akka.stream.alpakka.sqs.scaladsl.Integration")

  //#init-mat
  implicit val system = ActorSystem()
  implicit val mat = ActorMaterializer()
  //#init-mat

  val credentialsProvider = new AWSStaticCredentialsProvider(new BasicAWSCredentials("x", "x"))

  implicit val sqsClient = createAsyncClient(sqsEndpoint, credentialsProvider)

  def randomQueueUrl(): String = sqsClient.createQueue(s"queue-${Random.nextInt}").getQueueUrl

  override protected def afterAll(): Unit = {
    super.afterAll()
    sqsServer.stopAndWait()
    Await.ready(system.terminate(), 5.seconds)
  }

  def createAsyncClient(sqsEndpoint: String, credentialsProvider: AWSCredentialsProvider): AmazonSQSAsync = {
    //#init-client
    val client: AmazonSQSAsync = AmazonSQSAsyncClientBuilder
      .standard()
      .withCredentials(credentialsProvider)
      .withEndpointConfiguration(new EndpointConfiguration(sqsEndpoint, "eu-central-1"))
      .build()
    //#init-client
    client
  }

} 
开发者ID:akka,项目名称:alpakka,代码行数:55,代码来源:DefaultTestContext.scala

示例8: AkkaHttp

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

import java.nio.ByteBuffer

import akka.actor.ActorSystem
import akka.event.Logging
import akka.http.scaladsl.Http
import akka.stream.ActorMaterializer
import akka.http.scaladsl.server._
import com.amazonaws.auth.{AWSCredentialsProvider, BasicAWSCredentials}
import com.amazonaws.internal.StaticCredentialsProvider
import com.amazonaws.regions.{Region, Regions}
import com.amazonaws.services.kinesis.{AmazonKinesis, AmazonKinesisClient}
import com.amazonaws.services.kinesis.model.{PutRecordRequest, PutRecordResult}
import com.typesafe.config.ConfigFactory

object AkkaHttp extends App with Kinesis {
  implicit val system = ActorSystem()
  implicit val executor = system.dispatcher
  implicit val materializer = ActorMaterializer()

  val config = ConfigFactory.load()
  val logger = Logging(system, getClass)

  import Directives._

  val route: Route =
    path("order" / IntNumber) { id =>
      complete(id.toString)
    } ~
    parameters('key, 'value) { (key, value) =>
      if(accessKeyId.isDefined && secretAccessKey.isDefined) {
        put(key, value)
      }
      complete(s"key: ${key}, value: ${value}")
    }

  val bindingFuture = Http().bindAndHandle(route, config.getString("http.interface"), config.getInt("http.port"))

  override def put(key: String, value: String): PutRecordResult = {
    val credentialsProvider: AWSCredentialsProvider = new StaticCredentialsProvider(new BasicAWSCredentials(accessKeyId.get, secretAccessKey.get))
    val kinesis: AmazonKinesis = new AmazonKinesisClient(credentialsProvider)
    kinesis.setRegion(Region.getRegion(Regions.AP_NORTHEAST_1))
    val request: PutRecordRequest = new PutRecordRequest()
    request.setStreamName(streamName)
    request.setData(ByteBuffer.wrap(value.getBytes("UTF-8")))
    request.setPartitionKey(key)
    val putRecord: PutRecordResult = kinesis.putRecord(request)
    println(s"key:${key} ,record:${value}, ${putRecord}")
    println("--------")
    kinesis.putRecord(request)
  }
} 
开发者ID:shigemk2,项目名称:my-akka-http-sample,代码行数:54,代码来源:AkkaHttp.scala

示例9: FileDescriptorSpec

//设置package包名称以及导入依赖的类
package eu.shiftforward.apso.io

import com.amazonaws.auth.BasicAWSCredentials
import eu.shiftforward.apso.CustomMatchers
import eu.shiftforward.apso.aws.S3Bucket
import org.specs2.mutable.Specification

import scala.util.Try

class FileDescriptorSpec extends Specification with CustomMatchers {

  "A FileDescriptor" should {
    val fdConfig = config.Credentials(
      s3 = config.Credentials.S3(
        ids = Map("test" -> config.Credentials.S3.Entry("a", "b"))),
      sftp = config.Credentials.Sftp(
        default = Some(config.Credentials.Sftp.Entry.Basic("foo", "bar"))))

    "correctly be initialized given a URI with protocol" in {
      FileDescriptor("file:///tmp/folder") mustEqual LocalFileDescriptor("/tmp/folder")
      FileDescriptor("s3://tmp/path") mustEqual S3FileDescriptor("tmp/path")
      FileDescriptor("sftp://localhost/tmp/path", fdConfig) mustEqual SftpFileDescriptor("localhost/tmp/path", fdConfig.sftp)
      FileDescriptor("sftp://valid-host.com/tmp/path", fdConfig) mustEqual SftpFileDescriptor("valid-host.com/tmp/path", fdConfig.sftp)
    }

    "be serializable" in {
      FileDescriptor("file:///tmp/folder") must beSerializable
      FileDescriptor("s3://tmp/path") must beSerializable
      FileDescriptor("sftp://localhost/tmp/path", fdConfig) must beSerializable
    }

    "fail when initializing with an unsupported protocol" in {
      Try(FileDescriptor("wrongprotocol:///tmp")) must beAFailedTry
    }

    "fail when initializing without a protocol" in {
      Try(FileDescriptor("tmp")) must beAFailedTry
    }

    "be initialized with credentials when given a config" in {
      FileDescriptor("s3://test/path/path", fdConfig) match {
        case s3: S3FileDescriptor =>
          s3 must beSerializable
          s3.bucket must beEqualTo(new S3Bucket("test", () => new BasicAWSCredentials("a", "b")))
      }
    }
  }
} 
开发者ID:ShiftForward,项目名称:apso,代码行数:49,代码来源:FileDescriptorSpec.scala

示例10: Config

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

import com.amazonaws.auth.{AWSCredentials, BasicAWSCredentials}
import com.amazonaws.regions.Regions
import play.api.Configuration

class Config(orig: Configuration) {
  lazy val googleMapsKey: Option[String] = orig.getString("google.maps.key")
  lazy val amazon = orig.getConfig("amazon").map(new AmazonConfig(_))
  lazy val mail: Option[String] = orig.getString("management.mail")
}

class AmazonConfig(config: Configuration) {
  val regionRaw: Option[String] = config.getString("region")
  val access: Option[String] = config.getString("access_key")
  val secret: Option[String] = config.getString("secret_key")

  lazy val credentials: Option[AWSCredentials] = for {
    a <- access
    s <- secret
  } yield new BasicAWSCredentials(a, s)

  lazy val region: Option[Regions] = regionRaw.map(Regions.fromName)

  def ses: Option[MyAmazonSES] = for {
    c <- credentials
    r <- region
  } yield new MyAmazonSES(c, r)
} 
开发者ID:ponkotuy,项目名称:train-stamp-rally,代码行数:30,代码来源:Config.scala

示例11: AmazonDynamoDbConnection

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

import javax.inject.Inject

import com.amazonaws.auth.BasicAWSCredentials
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsyncClient
import com.github.dwhjames.awswrap.dynamodb.{AmazonDynamoDBScalaClient, AmazonDynamoDBScalaMapper}
import com.google.inject.ImplementedBy
import play.api.Configuration
import play.api.libs.concurrent.Execution.Implicits._

@ImplementedBy(classOf[AmazonDynamoDbConnection])
trait DynamoDbConnection {
  val db: AmazonDynamoDBScalaMapper
}

class AmazonDynamoDbConnection @Inject() (configuration: Configuration) extends DynamoDbConnection {
  private val credentials = new BasicAWSCredentials(
    configuration.getString("aws.accessKey").get,
    configuration.getString("aws.secretKey").get
  )
  private val sdkClient = new AmazonDynamoDBAsyncClient(credentials)
  private val client = new AmazonDynamoDBScalaClient(sdkClient)

  val db = AmazonDynamoDBScalaMapper(client)
}

class InMemoryDynamoDbConnection extends DynamoDbConnection {
  private val sdkClient = new AmazonDynamoDBAsyncClient(new BasicAWSCredentials("FAKE_ACCESS_KEY", "FAKE_SECRET_KEY"))
  sdkClient.setEndpoint("http://localhost:8000")
  private val client = new AmazonDynamoDBScalaClient(sdkClient)

  val db = AmazonDynamoDBScalaMapper(client)
} 
开发者ID:ArchDev,项目名称:dynamodb-rest-api,代码行数:35,代码来源:AmazonDynamoDBConnection.scala

示例12: LoadHitResultQueue

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

import com.amazonaws.auth.BasicAWSCredentials
import com.amazonaws.regions.{Region, Regions}
import com.amazonaws.services.lambda.runtime.Context
import com.amazonaws.services.sqs.AmazonSQSClient
import com.amazonaws.services.sqs.model.{CreateQueueRequest, GetQueueUrlRequest}
import com.fasterxml.jackson.databind.ObjectMapper
import com.typesafe.config.ConfigFactory
import vitomatic.model.SingleHitResult
import scala.util.Try


class LoadHitResultQueue {

  val objectMapper = new ObjectMapper()

  val config = ConfigFactory.load()

  lazy val awsCredentials = new BasicAWSCredentials(
    config.getString("aws.accessKeyId"),
    config.getString("aws.secretAccessKey"))

  val queueName = config.getString("aws.sqs.queueName")

  val sqs = new AmazonSQSClient(awsCredentials)
  sqs.setRegion(Region.getRegion(Regions.valueOf(config.getString("aws.region"))))

  def enqueue(data: SingleHitResult, ctx: Context): String = {
    val clientQueueName = s"${queueName}_${data.getClientId}"
    Try(sqs.createQueue(new CreateQueueRequest(clientQueueName)))
    val queueUrl = sqs.getQueueUrl(new GetQueueUrlRequest(clientQueueName)).getQueueUrl
    val json = objectMapper.writeValueAsString(data)
    val messageId = sqs.sendMessage(queueUrl, json).getMessageId
    messageId
  }

  def echo(data: String): String = {
    s"Hello ${data}"
  }

} 
开发者ID:vit-o-matic,项目名称:load-test-lambda,代码行数:43,代码来源:SQSProxyLambda.scala

示例13: SqsQueueService

//设置package包名称以及导入依赖的类
package me.davidvuong.http_api.utils

import com.amazonaws.AmazonWebServiceRequest
import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials}
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
import com.amazonaws.handlers.AsyncHandler
import com.amazonaws.services.sqs.model.{SendMessageRequest, SendMessageResult}
import com.amazonaws.services.sqs.{AmazonSQSAsync, AmazonSQSAsyncClientBuilder}

import scalaz._
import scalaz.concurrent.Task
import me.davidvuong.http_api.config.SqsConfig

case class SqsQueueService(config: SqsConfig) {
  val client: AmazonSQSAsync = AmazonSQSAsyncClientBuilder
    .standard
    .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(config.accessKey, config.secretKey)))
    .withEndpointConfiguration(new EndpointConfiguration(config.url, config.region))
    .build()

  def send(message: String): Task[SendMessageResult] = {
    Task.async[SendMessageResult] { k =>
      val request = new SendMessageRequest(config.url, message)
      client.sendMessageAsync(request, handler[SendMessageRequest, SendMessageResult](k))
    }
  }

  private def handler[E <: AmazonWebServiceRequest, A](k: (Throwable \/ A) => Unit) = new AsyncHandler[E, A] {
    override def onError(exception: Exception):    Unit = k(-\/(exception))
    override def onSuccess(request: E, result: A): Unit = k(\/-(result))
  }
} 
开发者ID:davidvuong,项目名称:docker-compose-bp,代码行数:33,代码来源:SqsQueueService.scala

示例14: PublisherExample

//设置package包名称以及导入依赖的类
package com.imageintelligence.fs2sqs.examples

import com.amazonaws.services.sqs.AmazonSQSAsyncClient
import com.amazonaws.services.sqs.model._
import fs2.Stream
import java.util.concurrent.Executors

import cats.effect.IO
import com.amazonaws.auth.BasicAWSCredentials
import com.imageintelligence.fs2sqs.FS2SQS
import fs2._

import scala.concurrent.ExecutionContext

object PublisherExample {

  def loggingSink[F[_], A]: Sink[F, A] = { s =>
    s.map { i =>
      println(i)
    }
  }

  def main(args: Array[String]): Unit = {
    val tp = Executors.newFixedThreadPool(4)
    implicit val ec = ExecutionContext.fromExecutorService(tp)
    val credentials = new BasicAWSCredentials(sys.env("AWS_ACCESS_KEY"), sys.env("AWS_SECRET_KEY"))
    val client = new AmazonSQSAsyncClient(credentials)
    val queueUrl = "https://sqs.ap-southeast-2.amazonaws.com/1234/example"

    // Construct an infinite Stream SendMessageRequest's, with the same body "123"
    val messageRequestsStream: Stream[IO, SendMessageRequest] =
      Stream.constant(new SendMessageRequest(queueUrl, "123")).repeat

    // Construct a Publish pipe that can turn SendMessageRequest's into SendMessageResult's
    val publishPipe: Pipe[IO, SendMessageRequest, SendMessageResult] = FS2SQS.publishPipe(client)

    // Compose our stream and pipe.
    val effect = messageRequestsStream
      .through(publishPipe)
      .to(loggingSink)
      .onError(e => Stream.emit(println("Error: " + e.getMessage)))

    // Lift our effect into a Task, and run it.
    effect.run.unsafeRunSync()
  }
} 
开发者ID:ImageIntelligence,项目名称:fs2-sqs,代码行数:47,代码来源:PublisherExample.scala

示例15: tableNames

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

import com.amazonaws.services.dynamodbv2.model.DeleteTableRequest
import com.amazonaws.services.dynamodbv2.util.TableUtils
import com.amazonaws.services.dynamodbv2.document.DynamoDB
import org.scalatest._
import scala.concurrent.duration._
import com.amazonaws.auth.{ BasicAWSCredentials, AWSStaticCredentialsProvider }

trait DynamoTestClient {
  val dynamoPortKey = "dynamodb.local.port"

  val dynamoPort = sys.props.get(dynamoPortKey).getOrElse {
    throw new Exception(s"Failed to find $dynamoPortKey")
  }

  val credentials = new AWSStaticCredentialsProvider(new BasicAWSCredentials("", ""))
  lazy val client = Repl.dynamoClient(Some(s"http://127.0.0.1:$dynamoPort"), Some(credentials))
}

trait DynamoSpec
    extends BeforeAndAfterAll
    with BeforeAndAfterEach
    with DynamoTestClient { self: Suite =>

  def tableNames: Seq[String]

  lazy val dynamo = new DynamoDB(client)

  override def afterEach() = {
    super.afterEach()
    tableNames.foreach { tableName =>
      TableUtils.deleteTableIfExists(client, new DeleteTableRequest().withTableName(tableName))
    }
  }

  override def afterAll() = {
    super.afterAll()
    client.shutdown()
  }

} 
开发者ID:joprice,项目名称:dynamite,代码行数:43,代码来源:DynamoSpec.scala


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