Closing Connection Clarification
Expected behavior
I assumed (incorrectly) that the connections are automatically closed for each request. That's certainly my fault but either the documentation or the API should be improved to ensure connection are closed properly.
Actual behavior
Each connection must be manually closed after it is used.
Suggestion
I have two suggestions to better manage connections.
Improve Documentation
Improve documentation to better ensure connections are closed. For instance in the sample code, I'd add the close
here:
let result = try connection.set("my_key", to: "some value")
.flatMap { return connection.get("my_key") }
.flatMap { connection.close().transform($0) }
.wait()
In this sample the connection is closed while still returning the "some value"
.
Ensure Shutdown in EventLoop
I'd look at how SOTO and AsyncHTTPClient ensure that the client is shutdown inside each EventLoop. This might be the more long-term and challenging but perhaps consistent with other APIs.
RediStack version/commit hash
1.0.0-alpha.11
swift --version
)
Swift Version (output of 5.3.4
uname -a
)
OS version (output of AWS Lambda/Amazon Linux 2