File tree Expand file tree Collapse file tree
pramen/api/src/main/scala/za/co/absa/pramen/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717package za .co .absa .pramen .api
1818
19- import com .typesafe .config .Config
19+ import com .typesafe .config .{ Config , ConfigFactory }
2020import za .co .absa .pramen .api .app .PramenFactory
2121import za .co .absa .pramen .api .common .{BuildPropertiesRetriever , FactoryLoader }
2222import za .co .absa .pramen .api .lock .TokenLockFactory
2323import za .co .absa .pramen .api .status .{PipelineStateSnapshot , TaskResult }
2424
25+ import scala .util .Try
26+
2527/**
2628 * Pramen provides additional features via a client that you can access like this:
2729 * {{{
@@ -78,5 +80,23 @@ trait Pramen {
7880object Pramen {
7981 val PRAMEN_NOTIFICATION_BUILDER_FACTORY_CLASS = " za.co.absa.pramen.core.PramenImpl"
8082
83+ /**
84+ * Returns the instance of Pramen client.
85+ * Projects can depend only on `pramen-api`, but the implementation of this interface is in `pramen-core`.
86+ * IllegalArgumentException will be thrown if `pramen-core` is not in the runtime classpath or if the implementation
87+ * class cannot be loaded for some reason.
88+ */
8189 lazy val instance : Pramen = FactoryLoader .loadSingletonFactoryOfType[PramenFactory ](PRAMEN_NOTIFICATION_BUILDER_FACTORY_CLASS ).instance
90+
91+ /**
92+ * Returns the configuration of the currently running workflow.
93+ *
94+ * If no workflow is running at the moment, returns the default TypeSafe config
95+ * which combines reference.conf and application.conf.
96+ */
97+ def getConfig : Config = {
98+ Try {
99+ Pramen .instance.workflowConfig
100+ }.toOption.getOrElse(ConfigFactory .load())
101+ }
82102}
You can’t perform that action at this time.
0 commit comments