public OkReplayConfig build() { return new OkReplayConfig(this); } }
public Recorder(OkReplayConfig configuration) { this.configuration = configuration; configuration.registerListeners(listeners); }
/** * Starts the Recorder, inserting a tape with the specified parameters. * * @param tapeName the name of the tape. * @param mode the tape mode. If not supplied the default mode from the configuration is * used. * @param matchRule the rules used to match recordings on the tape. If not supplied a default is * used. * @throws IllegalStateException if the Recorder is already started. */ @SuppressWarnings("OptionalUsedAsFieldOrParameterType") public void start(String tapeName, Optional<TapeMode> mode, Optional<MatchRule> matchRule) { if (tape != null) { throw new IllegalStateException("start called when Recorder is already started"); } tape = getTapeLoader().loadTape(tapeName); tape.setMode(mode.or(configuration.getDefaultMode())); tape.setMatchRule(matchRule.or(configuration.getDefaultMatchRule())); configuration.interceptor().start(configuration, tape); for (RecorderListener listener : listeners) { listener.onRecorderStart(tape); } }
private boolean isHostIgnored(okhttp3.Request request) { return configuration.getIgnoreHosts().contains(request.url().host()); }
/** Not just a property as `tapeRoot` gets changed during constructor. */ private TapeLoader<? extends Tape> getTapeLoader() { return new YamlTapeLoader(configuration.getTapeRoot()); } }
/** * Hosts that are ignored by okreplay. Any connections made will be allowed to proceed * normally and not be intercepted. */ public Collection<String> getIgnoreHosts() { if (isIgnoreLocalhost()) { Set<String> set = new LinkedHashSet<>(ignoreHosts); set.addAll(Network.getLocalAddresses()); return Collections.unmodifiableSet(set); } else { return ignoreHosts; } }
/** * Starts the Recorder, inserting a tape with the specified parameters. * * @param tapeName the name of the tape. * @param mode the tape mode. If not supplied the default mode from the configuration is * used. * @param matchRule the rules used to match recordings on the tape. If not supplied a default is * used. * @throws IllegalStateException if the Recorder is already started. */ @SuppressWarnings("OptionalUsedAsFieldOrParameterType") public void start(String tapeName, Optional<TapeMode> mode, Optional<MatchRule> matchRule) { if (tape != null) { throw new IllegalStateException("start called when Recorder is already started"); } tape = getTapeLoader().loadTape(tapeName); tape.setMode(mode.or(configuration.getDefaultMode())); tape.setMatchRule(matchRule.or(configuration.getDefaultMatchRule())); configuration.interceptor().start(configuration, tape); for (RecorderListener listener : listeners) { listener.onRecorderStart(tape); } }
private boolean isHostIgnored(okhttp3.Request request) { return configuration.getIgnoreHosts().contains(request.url().host()); }
/** Not just a property as `tapeRoot` gets changed during constructor. */ private TapeLoader<? extends Tape> getTapeLoader() { return new YamlTapeLoader(configuration.getTapeRoot()); } }
/** * Hosts that are ignored by okreplay. Any connections made will be allowed to proceed * normally and not be intercepted. */ public Collection<String> getIgnoreHosts() { if (isIgnoreLocalhost()) { Set<String> set = new LinkedHashSet<>(ignoreHosts); set.addAll(Network.getLocalAddresses()); return Collections.unmodifiableSet(set); } else { return ignoreHosts; } }
public Recorder(OkReplayConfig configuration) { this.configuration = configuration; configuration.registerListeners(listeners); }
public OkReplayConfig build() { return new OkReplayConfig(this); } }