com.atlan.pkg.PackageContext.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of package-toolkit-runtime Show documentation
Show all versions of package-toolkit-runtime Show documentation
Atlan custom package runtime toolkit
/* SPDX-License-Identifier: Apache-2.0
Copyright 2023 Atlan Pte. Ltd. */
package com.atlan.pkg
import com.atlan.AtlanClient
import com.atlan.model.core.AtlanCloseable
import com.atlan.pkg.cache.CategoryCache
import com.atlan.pkg.cache.ConnectionCache
import com.atlan.pkg.cache.DataDomainCache
import com.atlan.pkg.cache.DataProductCache
import com.atlan.pkg.cache.GlossaryCache
import com.atlan.pkg.cache.LinkCache
import com.atlan.pkg.cache.TermCache
/**
* Context for a custom package, including its tenant connectivity (client), package-specific configuration,
* and any further asset caches for the package.
*
* @param config package-specific configuration
* @param client connectivity to the Atlan tenant
* @param reusedClient whether the client in this context is reused (if so, will not be automatically closed)
*/
class PackageContext(
val config: T,
val client: AtlanClient,
private val reusedClient: Boolean = false,
) : AtlanCloseable {
val glossaryCache = GlossaryCache(this)
val termCache = TermCache(this)
val categoryCache = CategoryCache(this)
val connectionCache = ConnectionCache(this)
val dataDomainCache = DataDomainCache(this)
val dataProductCache = DataProductCache(this)
val linkCache = LinkCache(this)
/** {@inheritDoc} */
override fun close() {
AtlanCloseable.close(glossaryCache)
AtlanCloseable.close(termCache)
AtlanCloseable.close(categoryCache)
AtlanCloseable.close(connectionCache)
AtlanCloseable.close(dataDomainCache)
AtlanCloseable.close(dataProductCache)
AtlanCloseable.close(linkCache)
if (!reusedClient) {
AtlanCloseable.close(client)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy