Skip to content

Commit

Permalink
Remove Guice boilerplate for KillQueryProcedure
Browse files Browse the repository at this point in the history
Make the procedure be declared as other procedures.
  • Loading branch information
findepi committed Aug 8, 2023
1 parent c76d4be commit 309b764
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import com.google.inject.Provider;
import io.trino.FullConnectorSession;
import io.trino.annotation.UsedByGeneratedCode;
import io.trino.dispatcher.DispatchManager;
Expand Down Expand Up @@ -44,6 +45,7 @@
import static java.util.Objects.requireNonNull;

public class KillQueryProcedure
implements Provider<Procedure>
{
private static final MethodHandle KILL_QUERY = methodHandle(KillQueryProcedure.class, "killQuery", String.class, String.class, ConnectorSession.class);

Expand Down Expand Up @@ -88,7 +90,8 @@ public void killQuery(String queryId, String message, ConnectorSession session)
}
}

public Procedure getProcedure()
@Override
public Procedure get()
{
return new Procedure(
"runtime",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.multibindings.ProvidesIntoSet;
import io.trino.connector.system.jdbc.AttributeJdbcTable;
import io.trino.connector.system.jdbc.CatalogJdbcTable;
import io.trino.connector.system.jdbc.ColumnJdbcTable;
Expand Down Expand Up @@ -72,7 +71,8 @@ public void configure(Binder binder)
globalTableBinder.addBinding().to(TableTypeJdbcTable.class).in(Scopes.SINGLETON);
globalTableBinder.addBinding().to(UdtJdbcTable.class).in(Scopes.SINGLETON);

Multibinder.newSetBinder(binder, Procedure.class);
Multibinder<Procedure> procedures = Multibinder.newSetBinder(binder, Procedure.class);
procedures.addBinding().toProvider(KillQueryProcedure.class).in(Scopes.SINGLETON);

binder.bind(KillQueryProcedure.class).in(Scopes.SINGLETON);

Expand All @@ -82,10 +82,4 @@ public void configure(Binder binder)
tableFunctions.addBinding().toProvider(ExcludeColumns.class).in(Scopes.SINGLETON);
tableFunctions.addBinding().toProvider(Sequence.class).in(Scopes.SINGLETON);
}

@ProvidesIntoSet
public static Procedure getKillQueryProcedure(KillQueryProcedure procedure)
{
return procedure.getProcedure();
}
}

0 comments on commit 309b764

Please sign in to comment.