This PR aims to solve the impossibility to use the package without dependencies in unit test environments.
RedisFactory is a protocol that defines how to produce RedisClients.
RedisConfigurationFactory is an abstract factory that produce RedisConfigurations, and provides several methods that replaces all RedisConfiguration constructors. This breaks current APIs
An instance of redis now can be configured as following:
try app.redis(.one).use(.standalone(hostname: "an-hostname", port: 6379, pool: .init(connectionRetryTimeout: .milliseconds(100)))) like we already do in Fluent.
RedisConfiguration conforms to RedisFactory and actually creates RedisClients where previously were done in RedisStorage.LifeCycle.
RedisStorage now stores RedisClient instead of RedisConnectionPool.
the only way to use func withBorrowedConnection is by down casting RedisClient to RedisConnectionPool with as? operator or an error will be trowed.
The package expose also another product XCTRedis similarly to XCTFluent
Some file/folder & code refactor.
XCTRedis
This product allows to stub responses of redis, also for PubSub in order to test applications without conditions in production code to exclude redis. Writing code for test is not the way.
ArrayTestRedisClient is a stub class for storing & manipulating responses.
User shall interact with this class like XCTFluent ArrayTestDatabase
DummyRedis is the actual RedisClient stored in RedisStorage during tests.
These instances are as many as the eventLoops of our application.
Each instance peek responses from same ArrayTestRedisClient
RedisStub is the actual factory to be used in tests.
Redis
RedisFactory
is a protocol that defines how to produceRedisClient
s.RedisConfigurationFactory
is an abstract factory that produceRedisConfiguration
s, and provides several methods that replaces allRedisConfiguration
constructors. This breaks current APIstry app.redis(.one).use(.standalone(hostname: "an-hostname", port: 6379, pool: .init(connectionRetryTimeout: .milliseconds(100))))
like we already do in Fluent.RedisConfiguration
conforms toRedisFactory
and actually creates RedisClients where previously were done inRedisStorage.LifeCycle
.RedisStorage
now storesRedisClient
instead ofRedisConnectionPool
.func withBorrowedConnection
is by down castingRedisClient
toRedisConnectionPool
withas?
operator or an error will be trowed.XCTRedis
similarly toXCTFluent
Some file/folder & code refactor.
XCTRedis
This product allows to stub responses of redis, also for PubSub in order to test applications without conditions in production code to exclude redis. Writing code for test is not the way.
ArrayTestRedisClient
is a stub class for storing & manipulating responses.ArrayTestDatabase
DummyRedis
is the actualRedisClient
stored inRedisStorage
during tests.ArrayTestRedisClient
RedisStub
is the actual factory to be used in tests.app.redis(.one).use(.stub(client: client))
Redis configuration provider + XCTRedis