-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efc6615
commit ef22b40
Showing
17 changed files
with
66 additions
and
106 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
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 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
struct EventStreams: Plugin { | ||
func registerServices(in app: Application) { | ||
func boot(app: Application) { | ||
app.container.register(EventBus()).singleton() | ||
} | ||
} |
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 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 |
---|---|---|
@@ -1,14 +1,12 @@ | ||
struct Schedules: Plugin { | ||
func registerServices(in app: Application) { | ||
app.container.register(Scheduler()).singleton() | ||
} | ||
let scheduler = Scheduler() | ||
|
||
func boot(app: Application) async throws { | ||
app.schedule(on: Schedule) | ||
func boot(app: Application) { | ||
app.container.register(scheduler).singleton() | ||
app.registerCommand(ScheduleCommand.self) | ||
} | ||
|
||
func shutdownServices(in app: Application) async throws { | ||
try await app.container.resolve(Scheduler.self)?.shutdown() | ||
func shutdown(app: Application) async throws { | ||
try await scheduler.shutdown() | ||
} | ||
} |
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 |
---|---|---|
@@ -1,34 +1,12 @@ | ||
import ServiceLifecycle | ||
|
||
/// A Plugin represents a modular component of an Alchemy application. They | ||
/// typically inject services into a container that can be used by other | ||
/// plugins and add functionality to an Application once it is loaded. | ||
/// A Plugin represents a modular component of an Alchemy application. | ||
public protocol Plugin { | ||
/// A label for this plugin, for registration in the app lifecycle. | ||
var label: String { get } | ||
|
||
/// Register any services to an Application. | ||
func registerServices(in app: Application) | ||
|
||
/// Setup this plugin for the given app. | ||
/// Start this plugin given an app. | ||
func boot(app: Application) async throws | ||
|
||
/// Any shutdown logic before services are deallocated from the container. | ||
func shutdownServices(in app: Application) async throws | ||
/// Shutdown the plugin that was booted on the given app. | ||
func shutdown(app: Application) async throws | ||
} | ||
|
||
public extension Plugin { | ||
var label: String { name(of: Self.self) } | ||
|
||
func registerServices(in app: Application) { | ||
// | ||
} | ||
|
||
func boot(app: Application) async throws { | ||
// | ||
} | ||
|
||
func shutdownServices(in app: Application) async throws { | ||
// | ||
} | ||
extension Plugin { | ||
public func shutdown(app: Application) async throws {} | ||
} |
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
Oops, something went wrong.