Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] Lifecycle management plugin interface OR Global resource management plugin interface #1238

civitaspo opened this issue Oct 13, 2019 · 1 comment


Copy link

@civitaspo civitaspo commented Oct 13, 2019

Hi all, I have a feature request: the lifecycle management plugin interface OR the global resource management plugin interface.

I wrote a plugin digdag-operator-pg_lock that can get locks by PostgreSQL(if you want to know detailed use case, see the plugin README). However I cannot control the connection pool effectively. This is because the current digdag plugin interface does not manage the lifecycle nor the global resource. I want to close the pool when the plugin cache is expired or to define the global connection pool.

Currently the plugin interface has configureBinder, but, even if I define a class as a singleton object in this method, the class does not become singleton.

default <T> void configureBinder(Class<T> type, Binder binder) {

Because the plugin cache is expired in 10 minutes and re-create the plugin with a new child injector (and the injector is not referenced anywhere after creating the providerClass instance).

return cacheBuilder.apply(plugins.withInjector(injector));

public <T> List<T> getServiceProviders(Class<T> type)
ImmutableList.Builder<T> builder = ImmutableList.builder();
for (Plugin plugin : plugins) {
Class<? extends T> providerClass = plugin.getServiceProvider(type);
if (providerClass != null) {
builder.add(getServiceProvider(providerClass, type, plugin));
private <T, E extends T> E getServiceProvider(Class<E> providerClass, Class<T> type, Plugin plugin)
return injector.createChildInjector((binder) -> {
plugin.configureBinder(providerClass, binder);

In addition, Guice does not manage the lifecycle.

So I'm in trouble because I can't implement a connection pool well. For the current digdag-operator-pg_lock implementation, the connection pool is closed with the finalize method, but it's not very good, I think.

That's why I want the feature. If you have any other good advice, please let me know...


This comment has been minimized.

Copy link

@civitaspo civitaspo commented Oct 15, 2019

How is the implementation like the below?
aaefa00...civitaspo:65ddc5035135a028445d767d63c3fb90192c26a6 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.