Skip to content

Commit

Permalink
Add a create method to the LocalNewSessionQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Apr 26, 2021
1 parent 921241d commit c13ec4e
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.SessionNotCreatedException;
import org.openqa.selenium.events.EventBus;
import org.openqa.selenium.grid.config.Config;
import org.openqa.selenium.grid.data.CreateSessionResponse;
import org.openqa.selenium.grid.data.NewSessionErrorResponse;
import org.openqa.selenium.grid.data.NewSessionRejectedEvent;
Expand All @@ -12,9 +13,14 @@
import org.openqa.selenium.grid.jmx.JMXHelper;
import org.openqa.selenium.grid.jmx.ManagedAttribute;
import org.openqa.selenium.grid.jmx.ManagedService;
import org.openqa.selenium.grid.log.LoggingOptions;
import org.openqa.selenium.grid.security.Secret;
import org.openqa.selenium.grid.security.SecretOptions;
import org.openqa.selenium.grid.server.EventBusOptions;
import org.openqa.selenium.grid.sessionqueue.NewSessionQueue;
import org.openqa.selenium.grid.sessionqueue.SessionRequest;
import org.openqa.selenium.grid.sessionqueue.config.NewSessionQueueOptions;
import org.openqa.selenium.grid.sessionqueue.config.SessionRequestOptions;
import org.openqa.selenium.internal.Either;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.http.Contents;
Expand Down Expand Up @@ -113,6 +119,22 @@ public LocalNewSessionQueue(
new JMXHelper().register(this);
}

public static NewSessionQueue create(Config config) {
LoggingOptions loggingOptions = new LoggingOptions(config);
Tracer tracer = loggingOptions.getTracer();

EventBusOptions eventBusOptions = new EventBusOptions(config);
SessionRequestOptions requestOptions = new SessionRequestOptions(config);
SecretOptions secretOptions = new SecretOptions(config);

return new LocalNewSessionQueue(
tracer,
eventBusOptions.getEventBus(),
requestOptions.getSessionRequestRetryInterval(),
requestOptions.getSessionRequestTimeout(),
secretOptions.getRegistrationSecret());
}

private void timeoutSessions() {
Instant now = Instant.now();

Expand Down

0 comments on commit c13ec4e

Please sign in to comment.