Can Fastify plugin encapsulation support phased rollout without downtime
0 reputation · 26 Oct 2024, 14:30 UTC
Migration goal and constraints
Goal is to migrate a small existing application to Fastify with no downtime, using the plugin system and lifecycle hooks for a phased rollout.
Encapsulation via avvio is intended to keep decorators and hooks scoped per plugin, preventing global state pollution during a partial migration. Graceful shutdown via .close() is expected to stop new connections while allowing in-flight requests to finish. Asynchronous plugin registration and strict JSON schema validation introduce uncertainty about startup ordering and request rejection behavior.
The decision point is whether the current plugin encapsulation and hook model can safely support request mirroring or canary routing without scope leakage or race conditions during registration.
Which lifecycle hook provides the correct point for canary routing without interfering with preHandler logic? Does the fastify-plugin wrapper preserve encapsulation when plugins are loaded asynchronously in a rolling update? When is .close() considered complete relative to plugin teardown?