NeuraLegion/cypress-har-generator

View on GitHub
src/cdp/DefaultConnectionFactory.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import type { ConnectionFactory, ConnectionOptions } from './ConnectionFactory';
import { RetryStrategy } from './RetryStrategy';
import type { Connection } from './Connection';
import { CDPConnection } from './CDPConnection';
import { Logger } from '../utils/Logger';

export class DefaultConnectionFactory implements ConnectionFactory {
  constructor(private readonly logger: Logger) {}

  public create({
    maxRetries,
    initialBackoff,
    maximumBackoff,
    ...options
  }: ConnectionOptions): Connection {
    const retryStrategy = new RetryStrategy(
      maxRetries,
      initialBackoff,
      maximumBackoff
    );

    return new CDPConnection(options, this.logger, retryStrategy);
  }
}