Skip to content

Commit

Permalink
Improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
m-barthelemy committed Apr 5, 2020
1 parent d36050d commit 8f0b699
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let package = Package(
],
dependencies: [
...
.package(url: "https://github.com/m-barthelemy/vapor-queues-fluent-driver.git", from: "0.0.10"),
.package(url: "https://github.com/m-barthelemy/vapor-queues-fluent-driver.git", from: "0.1.2"),
...
],
targets: [
Expand All @@ -56,29 +56,44 @@ let package = Package(

```

In your app configuration, configure and load this `Queues` driver:
 

In your app configuration (for example, `configure.swift`), make sure you first configure your Fluent database(s):
```swift
// Your normal Vapor4 database configuration.
...
app.databases.use(.postgres(configuration: dbConfig), as: .psql, isDefault: true)
...

// Ensure the table for storing jobs is created
...
app.migrations.add(JobModelMigrate())
import Vapor
import QueuesFluentDriver
...
...
// Your normal Vapor4 database configuration for your application.
app.databases.use(.postgres(configuration: dbConfig), as: .psql, isDefault: true)
...
```

 

This package needs a table, named `jobs`, to store the Vapor Queues jobs. Add `JobModelMigrate` to your migrations:
```swift
// Ensure the table for storing jobs is created
app.migrations.add(JobModelMigrate())
```

// load the driver
app.queues.use(.fluent(.psql))
 

Load the `QueuesFluentDriver` driver:
```swift
app.queues.use(.fluent(.psql))
```

You can optiinally create a dedicated Database, set to `isdefault: false` and with a custom `DatabaseID` and use it for your Queues.
In that case you would initialize thr Queues configuration like this:

 

You can optionally create a dedicated Database, set to `isdefault: false` and with a custom `DatabaseID` and use it for your Queues.
In that case you would initialize the Queues configuration like this:

```swift
let queuesDb = DatabaseID(string: "my_queues_db")
app.databases.use(.postgres(configuration: dbConfig), as: queuesDb, isDefault: false)
app.queues.use(.fluent(queuesDb))
let queuesDb = DatabaseID(string: "my_queues_db")
app.databases.use(.postgres(configuration: dbConfig), as: queuesDb, isDefault: false)
app.queues.use(.fluent(queuesDb))
```


Expand Down

0 comments on commit 8f0b699

Please sign in to comment.