Skip to content

Commit 5675372

Browse files
authored
RD-15710: Store the table definitions so that they are reused when tableDefinitions is called again (#37)
This upgrade of das-server permit to cache a DAS instance and reuse it when recreating the same DAS. The code change is to store table definitions once for all in a variable, so that if the same instance is reused, it can immediately return its table definitions.
1 parent 9ce7d23 commit 5675372

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,5 +213,5 @@ lazy val docker = (project in file("docker"))
213213
.settings(
214214
strictBuildSettings,
215215
dockerSettings,
216-
libraryDependencies += "com.raw-labs" %% "das-server-scala" % "0.1.5" % "compile->compile;test->test"
216+
libraryDependencies += "com.raw-labs" %% "das-server-scala" % "0.1.7" % "compile->compile;test->test"
217217
)

src/main/scala/com/rawlabs/das/salesforce/DASSalesforce.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ class DASSalesforce(options: Map[String, String]) extends DASSdk with StrictLogg
101101

102102
private val allTables = staticTables ++ dynamicTables ++ maybeDatedConversionRateTable
103103

104-
override def tableDefinitions: Seq[TableDefinition] = allTables.map(_.tableDefinition)
104+
// These are the table definitions that will be returned to the client. It's stored
105+
// in a val to avoid recalculating it every time it's accessed. We do that because we
106+
// don't expect the tables to change during the lifetime of the DAS instance.
107+
private val definitions = allTables.map(_.tableDefinition)
108+
109+
override def tableDefinitions: Seq[TableDefinition] = definitions
105110

106111
override def functionDefinitions: Seq[FunctionDefinition] = Seq.empty
107112

0 commit comments

Comments
 (0)