Commit Graph
215 Commits
Author SHA1 Message Date
Nathan Harris 57168eda35 Merge branch 'rename-errors' into 'master'
Rename `RedisNIOError` to `RedisClientError`

See merge request Mordil/swift-redis-nio-client!72
2019-07-09 02:42:13 +00:00
Nathan Harris 13432f0c09 Rename RedisNIOError to RedisClientError
Motivation:

To make it a little more generic, and to avoid turnover during renames (such as the planned rebranding in issue #61), `RedisClientError` more accurately reflects the source of the errors, as well as the responsibility of causing the bug.

Modifications:

- Rename `RedisNIOError` to `RedisClientError`
- Rename `RedisError` file to `RedisErrors`
- Add documentation of `RedisClientError`
- Remove no longer used `.unsupportedOperation(method:message:)` value
- Rename `.responseConversion(to:)` to `.failedRESPConversion(to:)`

Result:

Names of `RedisClientError` should be more descriptive, less prone to turnover, and more documented for users to understand the issues related to these thrown errors.
2019-07-08 19:34:57 -07:00
Nathan Harris 6c39eb3913 Merge branch '47-proposal-feedback' into 'master'
47 -- SSWG Review Feedback

Closes #55, #57, #54, #49, and #47

See merge request Mordil/swift-redis-nio-client!53
2019-07-09 02:33:42 +00:00
Nathan Harris 238ebb7496 Merge branch 'connection-refactor' into '47-proposal-feedback'
Refactor `RedisConnection`

See merge request Mordil/swift-redis-nio-client!71
2019-07-09 02:27:57 +00:00
Nathan Harris ea7c755d07 Refactor RedisConnection
Motivation:

During proposal review, and while working within the codebase, several issues were identified with how `RedisConnection` was architectured.

Modifications:

- Change implementation of `RedisConnection` in some areas for new logic of internal `ConnectionState`
- Change behavior of logging in a few places
- The initializer for `RedisConnection` is now **internal**
- How users can override the default `ClientBootstrap` for a connection is by passing an instance to the `.connect` static method
- Change unit tests to inherit from a common XCTestCase class that handles creation and cleanup of `RedisConnection` in tests
- Remove Redis namespace enum

Result:

The API for `RedisConnection` should be much simpler, with the implementation being less buggy.

This resolves issues #49, #54, and #57.
2019-07-05 11:29:35 -07:00
Nathan Harris b807af58b5 Use String Interpolation for Logging Metadata 2019-07-04 12:39:32 -07:00
Nathan Harris 2f21e2071b Merge branch '60-typesafe-sortedset' into '47-proposal-feedback'
60 -- Provide Strong Option Types in SortedSet Commands

See merge request Mordil/swift-redis-nio-client!70
2019-07-04 19:27:18 +00:00
Nathan Harris 6423299231 60 -- Provide Strong Option Types in SortedSet Commands
Motivation:

While working through issue #59, it was noticed just how "stringly" the SortedSet command options for `zadd`, `zinterstore`, and `zunionstore` were, and Swift provides ways of having strong type safety for these options.

Modifications:

- Add `RedisSortedSetAddOption` and `RedisSortedSetAggregateMethod` to replace the String API in `zadd`, `zinterstore`, and `zunionstore`
- Fix an implication of how `overestimatedCountBeingAdded` documentation for `Array where Element == RESPValue` for `add(contentsOf:overestimatedCountBeingAdded:_:)`

Result:

Users should have a more discoverable and straightforward way that isn't error prone for calling `zadd`, `zinterstore`, and `zunionstore` with Redis supported options.
2019-07-04 12:20:45 -07:00
Nathan Harris 392be14796 Merge branch '59-respconvertible-generics' into '47-proposal-feedback'
59 -- Use `RESPValueConvertible` as Generic Constraint

See merge request Mordil/swift-redis-nio-client!69
2019-07-04 18:01:21 +00:00
Nathan Harris fa227b0e08 59 -- Use RESPValueConvertible as Generic Constraint
Motivation:

Johannes continues to provide great insight, and correctly pointed out that `RESPValueConvertible` was being used as an "existential" in all cases.

This can cause unexpected type-erasure and introduce unnecessary cost overhead with dynamic dispatch when in most cases we know the exact value we want for `RESPValue` to execute commands.

Modifications:

- Add new extensions to `Array where Element == RESPValue` for appending and adding elements into them
- Change `RedisClient.send(command:with:)` to require `[RESPValue]` instead of `[RESPValueConvertible]` as the `with` argument type
- Change all instances of `RESPValueConvertible` being an "existential" type for method arguments to instead be a generic constraint

Result:

The library should be safeguarded from a class of bugs, with the use of `send` being a bit more straight forward, with some new convenience methods for `[RESPValue]` types.
2019-07-04 01:03:36 -07:00
Nathan Harris e964ba0429 Merge branch 'cleanup-unsafe' into '47-proposal-feedback'
Revisit `RESPValue` and `RESPValueConvertible` implementations.

See merge request Mordil/swift-redis-nio-client!67
2019-07-02 23:19:15 -07:00
Nathan Harris cd9bd04f73 Revisit RESPValue and RESPValueConvertible implementations.
Motivation:

Johannes provided a fair code review of the project and summarized his findings in issue #48, and one of the prime offenders was all of the `unsafe*` APIs (pointers, buffers, bytes)
that were used with `RESPValue` and `RESPValueConvertible`.

He also provided great feedback and pointed out good points of confusion with the API design of `RESPValue` and `RESPValueConvertible`.

Modifications:

- Return to using `Array` instead of `ContiguousArray` for `RESPValue.array` storage
- Update all documentation to be more thorough in explaining how the types should be used and conformed to.
- Remove all uses of `unsafe*` APIs where possible
- Change implementations to be a lot more type and memory safe, double checking assumptions
- Remove conformance to `ExpressibleBy*Literal` as it is too easy for users to shoot themselves in the foot and saves only a few characters over `.init(bulk:)`
- Create new `RedisNIOTestUtils` target for common test extensions, making them public
- Move most almost all implementations of `RESPValue` computed properties into the `RESPValueConvertible` conformances

Result:

Users should be more safeguarded by the API against unknowingly getting incorrect `RESPValue` representations, the API design of `RESPValue` and `RESPValueConvertible` should be much clearer,
and memory safety should be at a higher bar from these changes.

This resolves issues #55 & #48, and contributes to issue #47.
2019-07-02 23:19:15 -07:00
Nathan Harris f445822c23 Merge branch 'redis-command' into '47-proposal-feedback'
Rename `RedisCommandContext` to `RedisCommand`, improve `RedisCommandHandler`...

See merge request Mordil/swift-redis-nio-client!66
2019-07-02 23:19:14 -07:00
Nathan Harris 15a3c0383e Merge branch 'expire-timeout' into '47-proposal-feedback'
Update `RedisClient.expire` to no longer use `deadline` terminology.

See merge request Mordil/swift-redis-nio-client!65
2019-07-02 23:19:13 -07:00
Nathan Harris 5fb0bfca5c Rename RedisCommandContext to RedisCommand, improve RedisCommandHandler usage semantics, and cleanup documentation.
Motivation:

During proposal review, it was noted that `RedisCommandContext` was a bit misleading, and the hidden reference semantics worrisome.

In addition, several of parts of the documentation around `RedisCommandHandler` were weak or also misleading.

Modifications:

- Rename `RedisCommandContext` to just `RedisCommand`
- Update documentation to be more explicit about the module who owns the types being referenced
- Update documentation to call out explicit usage semantics and behavior
- Change `RedisCommandHandler` to close the socket connection on error thrown
- Rename the "base" Redis Channel Handlers to be more explicitly named

Result:

Users should have clearer documentation on what happens when using `RedisCommandHandler` and `RedisCommand` without hidden semantics.

This contributes to issue #47.
2019-07-02 23:19:13 -07:00
Nathan Harris b96f64c7d0 Update RedisClient.expire to no longer use deadline terminology.
Motivation:

During proposal review, it was appropriately pointed out that `RedisClient.expire` incorrectly mixes 'deadline' and 'timeout' terminology.

Modifications:

- Change references of 'deadline' to 'timeout' to follow Redis' established semantics for 'EXPIRE'
- Add additional unit test for `RedisClient.expire`

Result:

`RedisClient.expire` should now be more clear as to its semantics and not mix terminology incorrectly.

This contributes to issue #47
2019-07-02 23:19:13 -07:00
Nathan Harris c5241a461c Merge branch 'client-bootstrap' into '47-proposal-feedback'
Change `Redis.makeDefaultClientBootstrap` to `ClientBootstrap.makeRedisTCPClient`

See merge request Mordil/swift-redis-nio-client!64
2019-07-02 23:19:12 -07:00
Nathan Harris 5d232ad022 Change Redis.makeDefaultClientBootstrap to ClientBootstrap.makeRedisTCPClient
Motivation:

During proposal review, feedback was provided that the discoverability of the factory method for building a standard RESP `ChannelPipeline` was poor outside of documentation.

Modifications:

- Move `Redis.makeDefaultClientBootstrap` to `ClientBootstrap.makeRedisTCPClient`.
- Move the `channelInitializer` implementation into a new `Channel.addBaseRedisHandlers()` instance method.

Result:

Users should have an easier time discovering how to easily create baseline RESP `ChannelPipelines`.

This contributes to #47.
2019-07-02 23:19:12 -07:00
Nathan Harris dc0b7e8b7b Merge branch 'resp-translator-refactor' into '47-proposal-feedback'
Refactor `RESPTranslator` to mutate the passed `ByteBuffer` directly.

See merge request Mordil/swift-redis-nio-client!63
2019-07-02 23:19:11 -07:00
Nathan Harris 44c29169d1 Merge branch 'init-label' into '47-proposal-feedback'
Add `fromRESP` label to `RESPValueConvertible.init`

See merge request Mordil/swift-redis-nio-client!56
2019-07-02 23:19:10 -07:00
Nathan Harris b8c19488a7 Refactor RESPTranslator to mutate the passed ByteBuffer directly.
Motivation:

During proposal review, it was pointed out that the code with a position index was redundant and error prone over relying on `ByteBuffer`'s `readerIndex`.

Modifications:

Refactored `RESPTranslator` to rely on `ByteBuffer.readerIndex` for position of current parsing cursor,
and eliminated `ParsingResult` enum to instead return `RESPValue?`.

The implementation for writing out `RESPValue` has been expanded to `RESPValueConvertible` and moved to an extension of `ByteBuffer`.

Result:

Parsing `RESPValue` into and out of `ByteBuffer` should be less error-prone and more straight forward.

This contributes to issues #47 and #55
2019-07-02 23:19:10 -07:00
Nathan Harris f98b53e3e4 Merge branch 'final-channelhandler' into '47-proposal-feedback'
Make `RedisCommandHandler` final

See merge request Mordil/swift-redis-nio-client!55
2019-07-02 23:19:09 -07:00
Nathan Harris 60d5c4ce06 Add fromRESP label to RESPValueConvertible.init
Motivation:

During SSWG review, feedback was provided on the API design of the `RESPValueConvertible.init` signature and how it should appropriately follow Swift Design Guidelines regarding labels.

Modifications:

`RESPValueConvertible.init(_:` is now `RESPValueConvertible.init(fromRESP:)`.

Result:

There should be more clarity at the call site when initializing a type from a `RESPValue`.

This contributes to #47
2019-07-02 23:19:09 -07:00
Nathan Harris 1281724a83 Make RedisCommandHandler final
Motivation:

During SSWG review, feedback was provided that forced a re-evaluation of early design feedback interpretation on composability of RedisNIO.

First understanding was that the desire was to have "customization points" to gain benefits of implementation of RedisCommandHandler, while new understanding is that it just needs to be public in order for users to include it in their own custom ChannelPipeline schemes.

Modifications:

`RedisCommandHandler` is now a final class.

Result:

Users will no longer be able to subclass `RedisCommandHandler`, but gain a super slight performance increase.

This contributes to #47.
2019-07-02 23:19:08 -07:00
Nathan Harris cc477734c2 Merge branch '58-5.1-testing' into 'master'
58 -- Add Swift 5.1 and Nightly Build Testing

Closes #58

See merge request Mordil/swift-redis-nio-client!68
2019-07-03 06:05:07 +00:00
Nathan Harris 0eb3074406 58 -- Add Swift 5.1 and Nightly Build Testing 2019-07-02 22:59:47 -07:00
Nathan Harris 79757dc0eb Merge branch 'swifty-append' into 'master'
Swap `append(_:to:)` parameters in signature

See merge request Mordil/swift-redis-nio-client!62
1.0.0-alpha.3
2019-06-25 19:31:26 +00:00
Nathan Harris 8c676812a1 Swap append(_:to:) parameters in signature 2019-06-25 12:25:06 -07:00
Nathan Harris 0facb90674 Merge branch 'append' into 'master'
Adding append

See merge request Mordil/swift-redis-nio-client!61
2019-06-25 19:05:48 +00:00
Ondrej Rafaj b280af596d Adding append 2019-06-25 19:05:48 +00:00
Nathan Harris b5812484e4 Merge branch '50-rename-map' into 'master'
50 -- Rename `EventLoopFuture.mapFromRESP` to `convertFromRESPValue`

Closes #50

See merge request Mordil/swift-redis-nio-client!60
2019-06-25 05:11:05 +00:00
Nathan Harris c010e13b9e 50 -- Rename EventLoopFuture.mapFromRESP to convertFromRESPValue 2019-06-24 22:06:21 -07:00
Nathan Harris e0e5a68957 Merge branch '53-circular-buffer' into 'master'
53 -- Use `CircularBuffer` for `RedisCommandHandler` queue

Closes #53

See merge request Mordil/swift-redis-nio-client!59
2019-06-22 02:45:33 +00:00
Nathan Harris 88c6cfa2c8 53 -- Use CircularBuffer for RedisCommandHandler queue 2019-06-21 19:40:49 -07:00
Nathan Harris 5672c55560 Merge branch '51-ascii-init' into 'master'
51 -- Use `UInt8(ascii:)` for RESP Tokens

Closes #51

See merge request Mordil/swift-redis-nio-client!58
2019-06-22 02:11:52 +00:00
Nathan Harris b9d8af0f10 51 -- Use UInt8(ascii:) for RESP Tokens 2019-06-22 02:07:28 +00:00
Nathan Harris 6dc4864734 Merge branch '52-exported' into 'master'
52 -- Remove `@_exported` Usage

Closes #52

See merge request Mordil/swift-redis-nio-client!57
2019-06-22 02:05:00 +00:00
Nathan Harris 2f8520c43b 52 -- Remove @_exported Usage 2019-06-21 19:00:33 -07:00
Nathan Harris 531a7d4021 Merge branch 'add-port-static' into 'master'
Add static property for default RedisConnection port

See merge request Mordil/swift-redis-nio-client!51
1.0.0-alpha.2.1
2019-06-12 17:18:56 +00:00
Nathan Harris 73b3f5df32 Add static property for default RedisConnection port
Motivation:

The default port for Redis is well published to be 6379, and it is common to want to pass this value around or use it as a static default value in methods and initializers.

Modifications:

Add `RedisConnection.defaultPort` static property for all users to use, and update references of the `6379` literals to use new  the new property.

Result:

Users should have a reliable default defined to use everywhere to avoid bugs.
2019-06-12 10:11:53 -07:00
Nathan Harris 30733dea02 Merge branch 'fix-data-conversion' into 'master'
Fix `Data` Conversion to `RESPValue`

See merge request Mordil/swift-redis-nio-client!50
1.0.0-alpha.2
2019-06-11 20:26:06 +00:00
Nathan Harris 34647e1423 Fix Data Conversion to RESPValue
Motivation:

`Foundation.Data` was unexpectedly receiving `RESPValueConvertible` conformance through the `Collection` extension which lead to incorrect encoding.

Modifications:

Add explicit conformance to `RESPValueConvertible` for `Data`.

Result:

Users should see their `Data` encoding to RESP format as expected.
2019-06-11 13:20:24 -07:00
Nathan Harris 788f69dede Fix warning with default for RESPValue.description implementation. 1.0.0-alpha.1.1.1 2019-06-11 12:23:29 -07:00
Nathan Harris d4584924cf Improve debugging of RESPValue
Motivation:

Reading output from `RESPValue` existentials is entirely verbose and does not provide a human-readable description of what is being represented.

Modifications:

- Add conformance to `CustomStringConvertible` for `RESPValue`
- Remove redundant logging of arguments in `RedisConnection.send`

Result:

String representations of `RESPValue` should now be more readable for human to understand.
1.0.0-alpha.1.1
2019-06-11 12:16:22 -07:00
Nathan Harris d48485869d Merge branch 'docs-tweak' into 'master'
Fix README and API Docs

See merge request Mordil/swift-redis-nio-client!49
2019-06-07 01:52:35 +00:00
Nathan Harris 06c0aeed0a Fix README and API Docs
Motivation:

The emojis in the README were not rendered consistently in the docs and on different screen form factors making a poor UX.

Modifications:

The CI config now properly sends the custom theme to Jazzy, and the README no longer has the `:bell:` emoji in the disclaimer header.

Result:

A consistent UX with the README and proper API docs referring to GitLab
2019-06-06 18:40:32 -07:00
Nathan Harris 23a8d4455f Update README
Motivation:

After moving to GitLab, and while still having a GitHub mirror, it is important to drive people to the proper location for getting help and reporting bugs or feature requests.

Also, some information should be updated to include new tags, formatting, and a link to the new API docs.

Modifications:

README is updated to point users to the GitLab repository and to have up-to-date information about the project.

Result:

Users should know where to reach project maintainers and where to find documentation.
1.0.0-alpha.1
2019-06-06 18:00:42 -07:00
Nathan Harris 3b5faf0498 Merge branch '45-api-docs' into 'master'
45 -- Add API Documentation

See merge request Mordil/swift-redis-nio-client!48
2019-06-07 00:22:03 +00:00
Nathan Harris dd839fdf02 45 -- Add API Documentation
Motivation:

Users need a quick reference available online that is up to date.

Modifications:

Add CI job to generate and publish API docs with Jazzy

Result:

Users can view API docs that are updated when new releases are tagged at https://mordil.gitlab.io/swift-redis-nio-client
2019-06-06 17:17:29 -07:00
Nathan Harris 6f6fe74c92 Merge branch 'se-0226' into 'master'
Rename package to match repo

See merge request Mordil/swift-redis-nio-client!47
0.10.0
2019-06-06 22:19:12 +00:00