dbsystel / dbnetworkstack Goto Github PK
View Code? Open in Web Editor NEWDBNetworkStack is a network abstraction for fetching request and mapping them to model objects
License: MIT License
DBNetworkStack is a network abstraction for fetching request and mapping them to model objects
License: MIT License
For the following reasons, we want to try an other approach to represent requests:
NetworkRequestRepresenting
does not contain the whole URL to perform the request.NetworkRequestRepresenting
can be configured to be invalid. This is not ideal.
We aim for a solution that addresses these points. The proposed solution is to rewrite the NetworkRequestRepresenting
protocol that its only function is to return a valid URLRequest
.
In some situations it would be helpful to have a NetworkServiceMock where mocked responses can be defined before they are consumed.
Having an additional mock would bring the following benefits:
In addition the possibility to define a timing behaviour may be interesting. Something like:
Create a PullRequest Template containing:
When building DBNetworkStack with Carthage I get the following errors.
Done linting! Found 0 violations, 0 serious in 41 files.
swiftlint(8910,0x7000075e5000) malloc: *** error for object 0x7000075e2150: Non-aligned pointer being freed (2)
*** set a breakpoint in malloc_error_break to debug
/Users/dennis/Library/Caches/org.carthage.CarthageKit/DerivedData/9.4_9Q1019a/DBNetworkStack/1.1/Build/Intermediates.noindex/ArchiveIntermediates/DBNetworkStack/IntermediateBuildFilesPath/DBNetworkStack.build/Release-iphoneos/DBNetworkStack.build/Script-C60F0D0D1D9A76B90028C417.sh: line 6: 8910 Abort trap: 6 swiftlint
Command /bin/sh failed with exit code 134
** ARCHIVE FAILED **
The following build commands failed:
PhaseScriptExecution ๐ง\ Swift\ Lint /Users/dennis/Library/Caches/org.carthage.CarthageKit/DerivedData/9.4_9Q1019a/DBNetworkStack/1.1/Build/Intermediates.noindex/ArchiveIntermediates/DBNetworkStack/IntermediateBuildFilesPath/DBNetworkStack.build/Release-iphoneos/DBNetworkStack.build/Script-C60F0D0D1D9A76B90028C417.sh
(1 failure)
My current solution is to remove the SwiftLint build phase.
Could be helpful to inject some global configuration into each request. Like authentication headers or API keys
A better name could be NetworkTask
Error:
Signing /Users/travis/Library/Developer/Xcode/DerivedData/DBNetworkStack-gkizlcawqmitiocnuhdyinfispui/Build/Products/Debug-appletvsimulator/DBNetworkStackTests.xctest
** TEST FAILED **
The command "set -o pipefail && xcodebuild -scheme DBNetworkStack -destination "$DESTINATION" $ACTION $SIGN | xcpretty" exited with 65.```
Could NetworkError, etc
The methods returnSuccess and returnError of NetworkServiceMock should handle an empty callbacks stack gracefull. This means, when no request has been triggered, a return should not result in a crash.
Methods:
This could help to fix #26
Use a better model for concurrency.
Maybe support for futures similar to https://github.com/FutureKit/FutureKit
When starting a request with an empty path, a fatal error is thrown.
An empty path should be valid.
TravisCI should only run in one single container. This should decrease build times
In cases where starting a request is not possible (e.g. base url for BaseUrlKey is missing), requests must be able to fail.
One way would be to have an optional network task as return type.
Create a DBNetworkstack Implementation for Result Type/ Promise/Future
Travis should prove that build with carthage works
Tests are not executed on linux caused by swifts lack of dynamic test evaluation.
Generating the tests could be a solution. (https://oleb.net/blog/2017/03/keeping-xctest-in-sync/)
something like this, but more solid:
extension NetworkServiceProviding {
public func requestMulti<T, Result>(_ resources: [Resource<T>], mapToResult: @escaping ([T]) -> Result,
onCompletion: @escaping (Result) -> Void, onError: @escaping (NetworkError) -> Void) {
var results: [T?] = resources.map { _ in nil }
resources.enumerated().forEach({ i, resource in
request(resource, onCompletion: { result in
results[i] = result
let finalResult = results.flatMap { $0 }
if finalResult.count == resources.count {
onCompletion(mapToResult(finalResult))
}
}, onError: { err in
onError(err)
})
})
}
}
Suggestion:
On NetworkServiceMock.deinit
callbacks array must be empty, else fail test.
The current documentation regarding NetworkServiceMock is difficult to understand.
We should improve this and add a working example.
I was looking for an example to a POST request but couldn't find it in the readme.
And do I also expect a Resource after the POST when my Server is just answering with a 200 ok?
When getting and error & a response, the information of the response ist lost.
see https://oleb.net/blog/2018/03/making-illegal-states-unrepresentable/
In Addition to modify request in sync before executing, it is helpful to be able to do this async as well.
if [ \"${CONFIGURATION}\" != \"Release\" ]; then\nif which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\nfi\n
could fix this
Make NetworkResponseProcessing
a class which can be compose and not a protocol with default implementations
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.