Class MongoClientCloser

java.lang.Object
io.micronaut.configuration.mongo.core.MongoClientCloser
All Implemented Interfaces:
io.micronaut.runtime.graceful.GracefulShutdownCapable

@Singleton public final class MongoClientCloser extends Object implements io.micronaut.runtime.graceful.GracefulShutdownCapable
Tracks Mongo clients and delays bean destruction during Micronaut graceful shutdown.
Since:
6.0.0
Author:
graemerocher
  • Constructor Details

    • MongoClientCloser

      public MongoClientCloser()
  • Method Details

    • track

      public <T> T track(T client, Duration shutdownDelay)
      Track a client with its configured shutdown delay.
      Type Parameters:
      T - The mongo client type
      Parameters:
      client - The client
      shutdownDelay - The shutdown delay
      Returns:
      The client
    • untrack

      public void untrack(Object client)
      Stop tracking a client once bean destruction completes.
      Parameters:
      client - The client
    • shutdownGracefully

      public CompletionStage<?> shutdownGracefully()
      Specified by:
      shutdownGracefully in interface io.micronaut.runtime.graceful.GracefulShutdownCapable