structurizr / dsl

Structurizr DSL
https://docs.structurizr.com/dsl
Apache License 2.0
1.41k stars 265 forks source link

Cache plugin instances or provide an API to construct cacheable plugin instances #373

Closed bioform closed 9 months ago

bioform commented 11 months ago

Description

Each time we request the DSL file rendering, the structurizr creates a new class loader and constructs a new plugin instance. At the same time, the plugin initialization can take some time (for example to authenticate on third-party services).

So there is no possibility for caching any kind of information between the rendering requests (for example when using Structurizr Lite).

It would be good to have a kind of API(maybe an Interface that the plugin can implement), to let the engine know to cache the plugin instance.

WDYT?

Priority

I'm willing to add this feature myself and raise a PR (please confirm approach first)

More information

No response

simonbrowndotje commented 11 months ago

There are number of possible approaches here, but it depends what your desired goal and usage pattern is (e.g. multiple uses of a plugin instance within the same DSL parse through to having Lite reuse plugin instances until shutdown). If you're calling an external data source inside the plugin, you might want to consider caching that information to disk (next to the workspace.dsl file) as another viable alternative to avoiding any longer running tasks each time the DSL is reloaded.

simonbrowndotje commented 9 months ago

No response ... closing as stale.