swift-server/swift-service-lifecycle

Provide a `CancelOnGracefulShutdownService`

Ouverte

#163 ouverte le 31 oct. 2023

 (3 commentaires) (0 réaction) (0 personne assignée)Swift (48 forks)auto 404
good first issue

Métriques du dépôt

Stars
 (528 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

If an adopter already has a reference type that implements a run() method it is currently impossible to support ServiceLifecycle, even though the implementation works easily:

extension MyExistingService: Service {}

The reason for this is, that ServiceLifecycle uses gracefulShutdown to signal shutdown instead of Task cancellation. That is the correct call. However it is impossible to add gracefulShutdown support to object that already expose a run() method. That's why im proposing that ServiceLifecycle offers a CancelOnGracefulShutdownService<Underlying: Service>.

Guide contributeur