groupe-sii / ogham

Sending email, sms or whatever is a piece of cake
https://groupe-sii.github.io/ogham/
Apache License 2.0
21 stars 15 forks source link

Cleanup resources #90

Closed aurelien-baudet closed 4 years ago

aurelien-baudet commented 4 years ago

Some senders need to explictly clean opened resources (opened files, opened sockets or anything else that needs to explicitly close resources or free memory). This can be necessary in applications that create, destroy and recreate MessagingService instances.

A new interface Cleanable has been created but for now it is not called automatically. Several possibilities:

  1. Change every implementation to also implement Cleanable in order to transmit clean() calls everywhere
    • -- need to update all classes for a technical concern (not business one)
    • -- some implementations that delegates to several implementations may be hard to handle
  2. Change only builders that register implementations that need to be cleaned (instances that implement Cleanable)
    • + change is only located in builders that create the instances. An utility method can be used to track Cleanable instances into a registry.
    • ++ only implementations that need cleanup are modified
    • -- registry must be shared between all builders
  3. Use an static event system
    • ++ only implementations that need cleanup are modified
    • ++ builders are not modified
    • -- use of static method so can't use several distinct services
    • -- implementations need to know about event system
  4. Use of static registry
    • ++ only implementations that need cleanup are modified
    • ++ builders are not modified
    • -- use of static method so can't use several distinct services
    • -- implementations need to know about registry