Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow building a SQSClient from SDK client #32

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
satabin marked this conversation as resolved.
Show resolved Hide resolved

}
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/
Loading