Skip to content

Commit

Permalink
Merge branch 'main' into update/scala-collection-compat-2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sloshy authored May 24, 2022
2 parents e2cb76b + 9d53cd4 commit b5d6ed2
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
runner.dialect = scala213
version = "3.4.3"
version = "3.5.3"
maxColumn = 120
12 changes: 6 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//Core deps
val amazonV = "2.17.143"
val amazonV = "2.17.191"
val catsV = "2.7.0"
val catsEffectV = "3.3.6"
val fs2V = "3.2.5"
val catsEffectV = "3.3.12"
val fs2V = "3.2.7"
val log4catsV = "1.2.0"
val refinedV = "0.9.28"
val refinedV = "0.9.29"
val collectionCompatV = "2.7.0"

val catsCore = "org.typelevel" %% "cats-core" % catsV
Expand All @@ -22,8 +22,8 @@ val collectionCompat =
//Test/build deps
val munitV = "0.7.29"
val munitCatsEffectV = "1.0.7"
val scalaCheckV = "1.15.4"
val scalaCheckEffectV = "1.0.3"
val scalaCheckV = "1.16.0"
val scalaCheckEffectV = "1.0.4"

val catsEffectLaws =
"org.typelevel" %% "cats-effect-laws" % catsEffectV % "test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ final case class RefinedMessageWithAttributes[F[_]](
receiptHandle: RefinedReceiptHandle[F],
attributes: MessageAttributes
) extends BaseSqsMessage[F, VisibilityTimeout]
with WithAttributes
with WithAttributes
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ object RefinedSqsClient {
queueUrl,
settings.maxMessages.value,
settings.visibilityTimeoutSeconds.value,
settings.waitTimeSeconds.value
settings.waitTimeSeconds.value,
receiveAttrs = true
)
.map { m =>
val attributes = MessageAttributes.fromMap(
Expand Down Expand Up @@ -134,13 +135,22 @@ object RefinedSqsClient {
def sendMessage(queueUrl: String, messageBody: String): F[String] =
simpleClient.sendMessage(queueUrl, messageBody)

def sendMessage(queueUrl: String, messageBody: String, messageAttributes: Map[String, MessageAttributeValue]): F[String] =
def sendMessage(
queueUrl: String,
messageBody: String,
messageAttributes: Map[String, MessageAttributeValue]
): F[String] =
simpleClient.sendMessage(queueUrl, messageBody, messageAttributes)

def sendMessage(queueUrl: String, messageBody: String, delaySeconds: Int Refined DelaySeconds): F[String] =
simpleClient.sendMessage(queueUrl, messageBody, delaySeconds.value)

def sendMessage(queueUrl: String, messageBody: String, delaySeconds: Int Refined DelaySeconds, messageAttributes: Map[String, MessageAttributeValue]): F[String] =
def sendMessage(
queueUrl: String,
messageBody: String,
delaySeconds: Int Refined DelaySeconds,
messageAttributes: Map[String, MessageAttributeValue]
): F[String] =
simpleClient.sendMessage(queueUrl, messageBody, delaySeconds.value, messageAttributes)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ final case class MessageAttributes(
)

object MessageAttributes {
def fromMap(m: Map[MessageSystemAttributeName, String], other: Map[String, MessageAttributeValue]): MessageAttributes = {
def fromMap(
m: Map[MessageSystemAttributeName, String],
other: Map[String, MessageAttributeValue]
): MessageAttributes = {
import MessageSystemAttributeName._
val approxReceiveCount = m.get(APPROXIMATE_RECEIVE_COUNT).flatMap(toIntOption)
val approxFirstReceiveTimestamp = m.get(APPROXIMATE_FIRST_RECEIVE_TIMESTAMP).flatMap(toLongOption)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cats.syntax.all._
import cats.effect._
import fs2.Stream
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.sqs.model.QueueAttributeName.ALL
import software.amazon.awssdk.services.sqs.model._

import scala.jdk.CollectionConverters._
Expand Down Expand Up @@ -60,8 +61,8 @@ trait SimpleSqsClient[F[_]] {
messageAttributes: Map[String, MessageAttributeValue]
): F[String]

/** Send a message to an SQS queue. Allows specifying the seconds to delay the message (valid values
* between 0 and 900).
/** Send a message to an SQS queue. Allows specifying the seconds to delay the message (valid values between 0 and
* 900).
* @return
* The message ID string of the sent message.
*/
Expand All @@ -71,7 +72,7 @@ trait SimpleSqsClient[F[_]] {
delaySeconds: Int
): F[String]

/** Send a message with attributes to an SQS queue. Allows specifying the seconds to delay the message (valid values
/** Send a message with attributes to an SQS queue. Allows specifying the seconds to delay the message (valid values
* between 0 and 900).
* @return
* The message ID string of the sent message.
Expand All @@ -98,7 +99,7 @@ object SimpleSqsClient {
.visibilityTimeout(visibilityTimeoutSeconds)
.waitTimeSeconds(waitTimeSeconds)

val reqWithMaybeAttrs = (if (receiveAttrs) req.attributeNames(QueueAttributeName.ALL) else req).build
val reqWithMaybeAttrs = (if (receiveAttrs) req.attributeNames(ALL).messageAttributeNames(ALL.toString) else req).build

client
.receiveMessageStream(reqWithMaybeAttrs)
Expand Down Expand Up @@ -180,7 +181,7 @@ object SimpleSqsClient {
def sendMessage(
queueUrl: String,
messageBody: String,
delaySeconds: Int,
delaySeconds: Int
): F[String] = {
sendMessage(queueUrl, messageBody, delaySeconds, Map.empty[String, MessageAttributeValue])
}
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.22")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.3.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")

0 comments on commit b5d6ed2

Please sign in to comment.