Skip to content

Commit

Permalink
Merge pull request #32 from ybasket/main
Browse files Browse the repository at this point in the history
Allow building a SQSClient from SDK client
  • Loading branch information
satabin authored Sep 17, 2024
2 parents ae7364b + a4fc01f commit 49ca6ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,12 @@ object SQSClient {
}
.map(new SQSClient(_))

/**
* Creates an SQS client from a given instance of `SqsAsyncClient`.
*
* It is upon the caller to ensure closing of the underlying client once appropriate.
*/
def fromClient[F[_]](client: SqsAsyncClient)(implicit F: Async[F]): QueueClient[F] =
new SQSClient(client)

}
4 changes: 3 additions & 1 deletion docs/systems/sqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You can create a client to service bus queues by using the [AWS SQS][sqs] module
libraryDependencies += "com.commercetools" %% "fs2-queues-aws-sqs" % "@VERSION@"
```

For instance you can create a managed client via a region and credentials as follows.
For instance, you can create a managed client via a region and credentials as follows.

```scala mdoc:compile-only
import cats.effect.IO
Expand All @@ -26,4 +26,6 @@ The client is managed, meaning that it uses a dedicated HTTP connection pool tha

If integrating with an existing code base where you already have an instance of `SdkAsyncHttpClient` that you would like to share, you can pass the optional `httpClient` parameter. If passed explicitly, the client is not closed when the resource is released, and it is up to the caller to manage it.

For full customization, you can supply your own instance of `SqsAsyncClient` by using `SQSClient.fromClient`. Note that this requires explicit management of the underlying client's lifecycle.

[sqs]: https://aws.amazon.com/sqs/

0 comments on commit 49ca6ab

Please sign in to comment.