Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23c0378

Browse files
committed
Fix tests without a Redis client (disable jobs by default)
1 parent9495044 commit23c0378

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

‎.github/workflows/swift.yml‎renamed to ‎.github/workflows/test.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name:Test
1+
name:Tests
22

33
on:
44
push:
@@ -8,6 +8,7 @@ on:
88

99
jobs:
1010
test:
11+
name:Test on ubuntu-latest
1112
runs-on:ubuntu-latest
1213
steps:
1314
-name:Checkout code

‎README.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66

77
All of Monki Projects'[APIs](https://en.wikipedia.org/wiki/API) specifications (including this one's) are available in the[mp-api-specs](https://github.com/MonkiProjects/mp-api-specs) repository.
88

9+
##Environment variables
10+
11+
| Environment variable|
12+
| -----------------------|
13+
|`DATABASE_PORT`|
14+
|`DATABASE_USERNAME`|
15+
|`DATABASE_PASSWORD`|
16+
|`DATABASE_NAME`|
17+
|`ENABLE_JOBS`|
18+
|`START_IN_PROCESS_JOBS`|
19+
|`START_SCHEDULED_JOBS`|
20+
921
##How To Contribute
1022

1123
###Run the project

‎Sources/MonkiProjectsAPI/PlacemarksAPI/Services/PlacemarkService.swift‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ internal struct PlacemarkService: PlacemarkServiceProtocol {
126126
}
127127

128128
func triggerSatelliteViewLoading(for placemark:PlacemarkModel)->EventLoopFuture<Void>{
129+
guardEnvironment.get("ENABLE_JOBS")=="true"else{
130+
logger.info("Skipping placemark satellite view loading")
131+
returnself.eventLoop.makeSucceededVoidFuture()
132+
}
133+
129134
do{
130135
returnself.app.queues.queue(.placemarks, logger:self.logger, on:self.eventLoop)
131136
.dispatch(
@@ -142,6 +147,11 @@ internal struct PlacemarkService: PlacemarkServiceProtocol {
142147
}
143148

144149
func triggerLocationReverseGeocoding(for placemark:PlacemarkModel)->EventLoopFuture<Void>{
150+
guardEnvironment.get("ENABLE_JOBS")=="true"else{
151+
logger.info("Skipping placemark location reverse geocoding")
152+
returnself.eventLoop.makeSucceededVoidFuture()
153+
}
154+
145155
do{
146156
returnself.app.queues.queue(.placemarks, logger:self.logger, on:self.eventLoop)
147157
.dispatch(

‎Sources/MonkiProjectsAPI/configure.swift‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,30 @@ public func configure(_ app: Application) throws {
4545
app.migrations.add(PlacemarkModel.Migrations.all)
4646
try app.autoMigrate().wait()
4747

48-
// ConfigureRepositories
48+
// Configurerepositories
4949
app.placemarkRepository.use(PlacemarkRepository.init(database:))
5050
app.placemarkKindRepository.use(PlacemarkKindRepository.init(database:))
5151
app.placemarkDetailsRepository.use(PlacemarkDetailsRepository.init(database:))
5252
app.placemarkPropertyRepository.use(PlacemarkPropertyRepository.init(database:))
5353

54-
// ConfigureServices
54+
// Configureservices
5555
app.placemarkService.use(PlacemarkService.init(db:app:eventLoop:logger:))
5656
app.placemarkDetailsService.use(PlacemarkDetailsService.init(db:app:eventLoop:logger:))
5757

58-
// Configurequeues
58+
// Configurejobs
5959
try app.queues.use(.redis(url:Environment.get("REDIS_URL")??"redis://127.0.0.1:6379"))
60+
Jobs.addAll(to: app)
6061

61-
if app.environment!=.testing{
62-
// Start workers
63-
Jobs.addAll(to: app)
62+
ifEnvironment.get("START_IN_PROCESS_JOBS")=="true"{
6463
try app.queues.startInProcessJobs(on:.default)
6564
try app.queues.startInProcessJobs(on:.placemarks)
66-
//try app.queues.startScheduledJobs()
65+
}else{
66+
app.logger.info("Not starting in process jobs, enable them with `START_IN_PROCESS_JOBS`")
67+
}
68+
ifEnvironment.get("START_SCHEDULED_JOBS")=="true"{
69+
try app.queues.startScheduledJobs()
70+
}else{
71+
app.logger.info("Not starting scheduled jobs, enable them with `START_SCHEDULED_JOBS`")
6772
}
6873

6974
// Register routes

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp