Commit Graph

287 Commits

Author SHA1 Message Date
Nathan Harris b08ad5461a Rename Package to "RediStack"
Motivation:

SwiftPM as of Swift 5.2 introduces a new package dependency graph and package description that makes the current naming of RediStack awkward to pull in.

Modifications:

- Change: Package.name to be "RediStack"

The git repo will be renamed to "mordil/redistack" in addition to this change.

Result:

Fixes #72 and makes it seamless to pull in RediStack as a Swift package dependency.
1.0.0-alpha.8
2020-03-11 20:35:15 -07:00
Nathan Harris 973a9162af 70 -- Update SwiftMetrics for ecosystem compatability 2020-03-06 03:13:19 +00:00
Nathan Harris fb161021a9 Rename ELF.convertFromRESPValue to be an overload of map 2020-02-19 20:59:11 -08:00
Nathan Harris 6bd5df7d93 Add map overloads for casting RESPValue elements in a Collection 2020-02-19 20:44:27 -08:00
Nathan Harris 17fa5dad0a Cleanup Extensions by placing code in more appropriate places 2020-02-19 20:41:41 -08:00
Nathan Harris f2fb726904 Use latest Redis 5 in dev Docker Compose 2020-02-17 16:00:24 -08:00
Nathan Harris bd4a0dab84 Add documentation coverage badge to README 2020-02-04 23:10:18 -08:00
Nathan Harris b8bac7e896 Exclude Code Climate CI job for schedules 2020-02-04 22:45:39 -08:00
Nathan Harris 21d0a3120b Add code quality tracking from Code Climate 2020-02-04 22:33:33 -08:00
Nathan Harris a0b21e7b81 Update test matrix in README 2020-01-26 13:57:07 -08:00
Nathan Harris 02f3fb760c Update nightlies to use 'official' nightlies on all linux platforms 2020-01-26 13:16:10 -08:00
Nathan Harris 8e48e939e0 Update README to clarify Redis version support 2020-01-16 10:15:02 -08:00
Nathan Harris 4b2729c0ac Add Swift 5.2 branch testing to CI f10d6a0 Nathan Harris <nathan@mordil.info> Jan 16, 2020 at 08:08 2020-01-16 09:28:07 -08:00
Nathan Harris 6e45f56e00 Merge branch 'range-api' into 'master'
Rework SortedSet and List range APIs

See merge request Mordil/swift-redi-stack!98
2019-12-31 01:22:20 +00:00
Nathan Harris 249999851e Rework SortedSet and List range APIs
Motivation:

The SortedSet and List range commands (LTRIM, LRANGE, ZRANGE, etc.) are stringly-based and not flexible with Swift syntax.

Modifications:

- Add overloads of LTRIM that support the gambit of Range Standard Library types
- Rework LRANGE to mirror LTRIM method signatures
- Rework ZScore Range based commands to be more type-safe with `RedisZScoreBound` enum
- Rework ZLex Range based commands to be more type-safe with `RedisZLexBound` enum
- Rework ZCOUNT, ZLEXCOUNT, ZRANGE, ZREVRANGE, ZREMRANGEBYLEX, ZREMRANGEBYRANK, ZREMRANGEBYSCORE methods to be more type-safe and support Swift Range syntax

Result:

Working with SortedSet ranges should be much more type safe, and expressive with Swift's Range syntax.
2019-12-30 17:17:25 -08:00
Nathan Harris 47480b8074 Update Linux test manifest 2019-12-30 17:17:24 -08:00
Nathan Harris 346d37d636 Merge branch 'revisit-zadd' into 'master'
Revisit the SortedSet `zadd` command API

See merge request Mordil/swift-redi-stack!97
2019-12-28 07:58:24 +00:00
Nathan Harris 8e3d8f6faf Revisit the SortedSet zadd command API
Motivation:

While reviewing the API, the current design does not read well, and still has room for misunderstanding the actual end result of a ZADD operation.

Modifications:

- Rename `RedisSortedSetAddOption` to `RedisZaddInsertBehavior` and update cases to match desired use site syntax.
- Add `RedisZaddReturnBehavior` enum to define how `zadd` should calculate the return value.
- Update `zadd` and its overloads to support the two new enums in the form of `zadd(_:to:inserting:returning:)`

Result:

The more "Swifty" API will make it much more clear to developers at the call site what the actual behavior of the ZADD command will be.
2019-12-27 23:49:44 -08:00
Nathan Harris 4350e01097 Merge branch 'blocking-timeamount' into 'master'
Use `TimeAmount` for any `timeout` command arguments

See merge request Mordil/swift-redi-stack!96
2019-12-28 06:35:14 +00:00
Nathan Harris 1ef315e255 Use TimeAmount for any timeout command arguments
Motivation:

The goal is to have a strong-typed API for type-safety in arbitrary values, such as trying to use
Int to represent time - as '3' could mean any unit of time, leaving many places for errors and bugs.

Modifications:

Switch all current APIs that accept a `timeout` argument to use `NIO.TimeAmount` instead of a plain `Int`.

Result:

Developers will have an easier time reasoning about their own code as to what values might mean when working with
timeouts in Redis APIs.
2019-12-27 22:29:28 -08:00
Nathan Harris 0007a08697 Merge branch 'isconnected-req' into 'master'
Add `isConnected` property to `RedisClient` protocol

See merge request Mordil/swift-redi-stack!95
2019-12-28 06:13:16 +00:00
Nathan Harris a50a4d555d Add isConnected property to RedisClient protocol
Motivation:

It it pretty common as a developer when working with connections and "database" clients to want to know
if the connection is currently open before doing any work.

Modifications:

Add `var isConnected: Bool { get }` requirement to the `RedisClient` protocol

Result:

Developers should now have access to the connectivity state of any `RedisClient`
2019-12-27 21:52:20 -08:00
Nathan Harris a5f9d76cac Merge branch 'typed-keys' into 'master'
Add type-safe representation of Redis keys

See merge request Mordil/swift-redi-stack!93
2019-12-28 05:42:08 +00:00
Nathan Harris ea6f427993 Add type-safe representation of Redis keys
Motivation:

Inspired by Swift by Sundell's article on type-safe identifers, the goal of this commit is to have the compiler
assist in preventing incorrect Redis key values from being used in API calls.

See https://www.swiftbysundell.com/articles/type-safe-identifiers-in-swift/ for the inspiration.

Modifications:

- Add new `RedisKey` struct that wraps around a single `String` value that conforms to several expected protocols
  (Hashable, Comparable, Codable, etc.)
- Change all command APIs to require `RedisKey` rather than plain strings

Result:

When encountering an API requiring a RedisKey, it should be much more apparant at the use site what form a value should take.
2019-12-27 21:38:35 -08:00
Nathan Harris 5d6c3d3f28 Merge branch 'authorize' into 'master'
Add authorize command

See merge request Mordil/swift-redi-stack!94
2019-12-25 08:28:40 +00:00
Nathan Harris 435cdb2ab0 Add authorize command
Motivation:

The library provides command implementations for almost every single Redis command, authorize is no different.

Modifications:

Add `authorize(with:)` command method on `RedisClient`
Replace the implementation in `RedisConnection.connect(...)`

Result:

Developers should now have independent access to the `AUTH` Redis command on `RedisClient` implementations.
2019-12-25 00:23:09 -08:00
Nathan Harris 8d85cb2bfa Update to use new NIOAtomic over deprecated Atomic 1.0.0-alpha.7.1 2019-12-16 15:47:03 -08:00
Nathan Harris 9747cf2e2b Merge branch 'custom-logging' into 'master'
Revist user Logging configuration for connections and clients

See merge request Mordil/swift-redi-stack!92
1.0.0-alpha.7
2019-12-13 23:47:32 +00:00
Nathan Harris 209ba87bf5 Revisit user Logging configuration for connections and clients
Motivation:

Logging is more dynamic in real world usage than the current static heavy API allows.

Users generally want to be capable of updating connection logger metadata to attach dynamic properties such as an HTTP request ID for log tracing.

Modifications:

- Move all logs to `RedisConnection`
- Add `id: UUID` property to `RedisConnection`
- Add `logging` property and `setLogging(to:)` method requirements to `RedisClient`
- Add chainable `logging(to:)` method extension to `RedisClient`
- Add additional `trace` log statements to `RedisConnection`
- Change when `RedisConnection.init` logging and metric calls are made
- Change some `debug` log statements to `trace in `RedisConnection`

Result:

Users should have infinitely more flexibility in how RedisConnection, and RedisClient  implementations in general, behave in regards to logging.
2019-12-13 23:47:32 +00:00
Nathan Harris e0ebf9266b Merge branch 'variadic-overloads' into 'master'
Add variadic overloads for several commands

See merge request Mordil/swift-redi-stack!87
1.0.0-alpha.6.1
2019-10-27 07:01:05 +00:00
Nathan Harris adcff65030 Add variadic overloads for several commands
Motivation:

For ergonomics, users sometimes want to provide arguments as a variadic list rather than an array.

Modifications:

- Add variadic overloads for almost all methods that accept lists of homogenous types

Result:

Users should have more flexibility in the way arguments are passed to command methods
2019-10-26 23:55:47 -07:00
Nathan Harris 8ce1dd8257 Merge branch 'generic-get' into 'master'
Add RedisClient.get generic overload

See merge request Mordil/swift-redi-stack!86
2019-10-27 06:28:52 +00:00
Nathan Harris 9e5179f3e4 Add RedisClient.get generic overload
Motivation:

It is wrong to always assume that a GET operation is expecting a String response type, as users may be storing other types of data.

Modifications:

- Add `get` generic method with a constraint for types of `RESPValueConvertible` to convert values to the user desired type
- Change existing `get` method to specialize the generic overload
- Fix incorrect doc block regarding the ELF failure condition

Result:

Users should now be able to specialize the return type of a "GET" command
2019-10-26 22:50:58 -07:00
Nathan Harris 5c39c83663 Add dev Docker Compose file 2019-10-26 22:47:23 -07:00
Nathan Harris a3f6d3b834 Merge branch 'remove-assertions' into 'master'
Remove unnecessary assertions in `RedisCommandHandler`

See merge request Mordil/swift-redi-stack!85
2019-10-07 14:38:33 +00:00
Nathan Harris ba66ebf81e Remove unnecessary assertions in RedisCommandHandler
Motivation:

The assertions in `errorCaught(context:error:)` and `channelRead(context:data:)` are holdovers from when SwiftLog was not integrated into the package. The conditions where they were triggered are safely handled in other ways, so the asserts are not guarding against undefined behavior or bad app state.

Modifications:

Remove the two asserts regarding the `RedisCommandHandler.commandResponseQueue` to rely on Logging to bubble up errors to the user.

Result:

Debug builds using RediStack should not encounter unexpected assertions and should rely on other, better, error handling.

This contributes to issue #65
2019-10-07 07:24:00 -07:00
Nathan Harris 237f049c81 Merge branch 'thread-sanitizer' into 'master'
Run thread sanitizer on 5.1 test CI jobs

See merge request Mordil/swift-redi-stack!84
1.0.0-alpha.6
2019-09-24 03:06:15 +00:00
Nathan Harris 939e41b832 Fix data race with RedisMetrics.activeConnectionCount
Motivation:

After enabling the thread sanitizer during testing, a data race with the `activeConnectionCount` in `RedisMetrics` was caught due to changing a primitive `Int` across threads.

Modifications:

Add a specialized class `ActiveConnectionGauge` to wrap the semantics of the `activeConnectionCount` with an `Atomic<Int>` property.

Result:

No data races should occur with the `RedisMetrics` subsystem.
2019-09-23 20:03:20 -07:00
Nathan Harris dfca57046c Run thread sanitizer on 5.1 test CI jobs
Motivation:

Now that SwiftPM with 5.1 supports Linux thread sanitizers, we should run this as part of the normal test pass to catch threading issues.

Modifications:

Add `--sanitize=thread` argument to `swift test` commands for any job that runs Swift >=5.1.

Result:

More bugs should be caught as soon as possible now that thread races are being monitored.
2019-09-23 19:36:07 -07:00
Nathan Harris 2a27a598c3 Merge branch 'update-test-matrix' into 'master'
Update Test Matrix to include Swift 5.1 Official Release

See merge request Mordil/swift-redi-stack!83
2019-09-24 02:27:45 +00:00
Nathan Harris 3c4b5c407a Update Test Matrix to include Swift 5.1 Official Release
Motivation:

With the release of Swift 5.1, the official docker containers are available for both 16.04 and 18.04 of Linux - so the test matrix should include them.

Modifications:

- Add new 5.1 jobs for 18.04 linux and change 16.04 5.1 jobs to use the official docker images.
- Update the README to capture the changes

Result:

The number of configurations the library is tested against should be as wide as possible for regular interval testing passes.
2019-09-23 19:19:31 -07:00
Nathan Harris 9741a2ef4f Merge branch 'respvalue-nil-init' into 'master'
Change `RESPValue.init(bulk:)` initializers to accept a wider range of values

See merge request Mordil/swift-redi-stack!81
2019-07-29 05:19:09 +00:00
Nathan Harris 479c024d4b Change RESPValue.init(bulk:) initializers to accept a wider range of values
Motivation:

While working to add more test coverage with `RESPTranslator`, it was made apparent that a `.bulkString(.none)` is impossible to create directly with the `RESPValue` initializers, even though it is a reasonable possibility.

Additionally, forcing all integer types to have to be stored in an `Int` is unnecessarily restrictive.

Modifications:

- Change `RESPValue.init(bulk:)` initializers to accept `Optional` instances
- Change `RESPValue.init(bulk:)` for `Int` initializer to be generic on `FixedWidthInteger`

Result:

Converting types to and from `RESPValue` should be more bi-directional and seamless.
2019-07-29 05:05:39 +00:00
Nathan Harris b70923623b Merge branch 'more-resptranslator-tests' into 'master'
Add more test coverage of `RESPTranslator`

See merge request Mordil/swift-redi-stack!82
2019-07-29 05:04:19 +00:00
Nathan Harris b9b703078e Add more test coverage of RESPTranslator
Motivation:

Diagnostics for why `.bulkString` parses might fail were weak, and edge cases fell through gaps in coverage were found.

Modifications:

Added new cases to `RESPTranslator.ParsingError` for `.bulkString` parsing with additional test coverage.

Result:

Users should have better diagnostics for bogus data or failed parsing state.
2019-07-28 21:42:43 -07:00
Nathan Harris 8c3bdbac86 Merge branch 'update-linuxmain' into 'master'
Add missing `ByteToMessageDecoderVerifier` tests to Linux Main

See merge request Mordil/swift-redi-stack!80
2019-07-29 03:25:48 +00:00
Nathan Harris 0d4b520bb7 Add missing ByteToMessageDecoderVerifier tests to Linux Main
Motivation:

While working on issue #56, it was forgotten to add the new test cases to the linux manifest file.

Modifications:

Update the linux manifests to include all current unit tests

Result:

All written unit tests should be ran on Linux
2019-07-28 20:23:09 -07:00
Nathan Harris 879afb4c27 Merge branch 'faster-mr-ci' into 'master'
Speed up CI pipelines for Merge Requests

See merge request Mordil/swift-redi-stack!79
2019-07-29 03:18:16 +00:00
Nathan Harris 02d8d02176 Speed up CI pipelines for Merge Requests
Motivation:

MRs take unnecessarily too long to have completed pipelines with "redundant" builds happening in sequence.

The entire stage of building in release is an additional QA layer that can happen on merges into master, but for MRs are just added CPU cycles.

While it's useful to ensure that building in release is possible, we will get almost all build failures from the test stage, and the most important checks are the unit and integration tests.

Modifications:

Change the ordering of build vs. test, as well as only running "build in release" jobs on the master branch.

Result:

MRs should be able to be merged sooner as CI pipelines take less time to run.
2019-07-28 20:12:21 -07:00
Nathan Harris 50dba5c93a Merge branch '56-b2m-verifier-tests' into 'master'
56 -- Add `ByteToMessageDecoderVerifier` unit tests

Closes #56

See merge request Mordil/swift-redi-stack!78
2019-07-29 03:11:51 +00:00