I'm interested to know if there is an official or accepted way to achieve the following:
I have a model that is persisted to a postrgresql database. I also have an indexing service based on elasticsearch. For example, I would like to use the didUpdate lifecycle event on the PostgreSQL model to pass the model through to the indexing service. didCreate looks like this:
public func didUpdate(on conn: PostgreSQLConnection) throws -> EventLoopFuture<Account>
Now the problem here is that I don't have access to a container, only a connection - and by extension - an EventLoop.
I think the naive way of solving this would be to make the application a global object, allowing me to request a service from it. What I am curious about is whether Vapor has some mechanism that I haven't come across that allows an elegant way of achieving this?