-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolver based services abstraction for data access (#61)
* Site settings moved to Site Service with injection * Add and adopt services for other entities * Buffer for Sites/Species/Supervisors; use services for upload session * Resolver for all db / api refs; retire EntitiesViewModel * Version bump * Integration tests and necessary config wrap for CI * Move other entity services to use Session Factory * Fix flaky test
- Loading branch information
Showing
32 changed files
with
765 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Resolver | ||
import Photos | ||
import UIKit | ||
|
||
extension Resolver: ResolverRegistering { | ||
|
||
static let mock = Resolver(child: main) | ||
static let integrationTest = Resolver(child: main) | ||
|
||
public static func registerAllServices() { | ||
// register all components as singletons for lifetime of application | ||
// defaultScope = .application | ||
|
||
// MARK: Base services | ||
register { Logger(output: .print) }.implements(Logging.self) | ||
register { Database(logger: resolve()) } | ||
register { AlamofireApi(logger: resolve()) }.implements(Api.self) | ||
register { Defaults() } | ||
register { GRDBImageCache(logger: resolve()) } | ||
register { UIScreenLockManager() } | ||
register { PHCachingImageManager() } | ||
register { RecentSpeciesManager(defaults: resolve(), strategy: .todayUsedSpecies) } | ||
|
||
// MARK: Services | ||
register { AirtableSessionFactory(airtableBaseId: Constants.Airtable.baseId, | ||
airtableApiKey: Constants.Airtable.apiKey, | ||
httpRequestTimeoutSeconds: Constants.Http.requestTimeoutSeconds, | ||
httpWaitsForConnectivity: true, | ||
httpRetryDelaySeconds: Constants.Http.requestRetryDelaySeconds, | ||
httpRetryLimit: Constants.Http.requestRetryLimit) } | ||
register { AirtableSiteService() as SiteService } | ||
register { AirtableSpeciesService() as SpeciesService } | ||
register { AirtableSupervisorService() as SupervisorService } | ||
|
||
// MARK: Controllers | ||
register { SitesController() } | ||
register { SpeciesController() } | ||
register { SupervisorsController() } | ||
register { SettingsController(style: UITableView.Style.grouped) } | ||
|
||
// MARK: test component registrations | ||
mock.register { MockApi() as Api } | ||
|
||
integrationTest.register { AirtableSessionFactory(airtableBaseId: Secrets.testAirtableBaseId, | ||
airtableApiKey: Secrets.testAirtableApiKey, | ||
airtableTablePrefix: Secrets.testAirtableTableNamePrefix, | ||
httpRequestTimeoutSeconds: Constants.Http.requestTimeoutSeconds, | ||
httpWaitsForConnectivity: true, | ||
httpRetryDelaySeconds: Constants.Http.requestRetryDelaySeconds, | ||
httpRetryLimit: Constants.Http.requestRetryLimit) } | ||
|
||
if CommandLine.arguments.contains("--mock-server") { | ||
Resolver.root = Resolver.mock | ||
} | ||
|
||
if CommandLine.arguments.contains("--integration-test") { | ||
Resolver.root = Resolver.integrationTest | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Foundation | ||
|
||
enum DataAccessError: Error { | ||
case remoteError(errorCode: Int, errorMessage: String) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.