ArtifactStore SPI exposes a shutdown method which is responsible for closing any resource owned by store implementation.
Ccurrently for CouchDbRestStore it only shuts down ActorMaterializer which is created one per instance. It does not shutdown Http pool which is shared across 3 store instance. This is documented in PoolingRestClient. Now with CosmosDBArtifactStore we need to share a `DocumentClient` instance which owns the underlying Netty connection pool. As all the store instance talk to same db it makes sense to share the instance. However this sharing poses problem with shutdown. To handle that CosmosDB PR introduces a `CountedReference` [1] which keeps an open/close count and only closes when all references are closed. Wanted to check with team if that would be fine approach to take? Currently its bit tricky to manage components lifecycle and often we need to rely on shutdown hooks to close the resources properly. May be we revisit SPI/component lifecycle handling later and then review this shutdown method handling Chetan Mehrotra [1] https://github.com/apache/incubator-openwhisk/pull/3562/files#diff- 9d57de71410575fd70240ac974be407d