Skip to content

eotsevych/pw-object-pool

Repository files navigation

Project Overview

This project is a TypeScript-based application that includes various tests for user pool management using Playwright. The project uses different testing strategies to ensure the proper functioning of user acquisition and release mechanisms.

List of Object Pool Pattern Implementations

  • centralized: Centralized Locking Mechanism (Working solution if no horizontal scaling is required)
  • express: REST API for managing a user pool using Express.js, async-mutex (For horizontal scaling need to start Server before running tests)

Examples of other implementations which are not working solutions

  • file: File-based user pool manager (No synchronization mechanism is implemented)
  • mutex: Custom Mutex implementation (Each worker creates its own mutex)

Installation

To install the project dependencies, run:

npm install

Express API

API server stars at `http://localhost:3002 automatically thanks to the playwright webServer configuration.

webServer: {
     command: 'npx ts-node express/express.up.ts',
     port: 3002,
     reuseExistingServer: !process.env.CI,
     timeout: 5 * 1000,
   }

API Endpoints

  • acquire: POST /acquire
curl -X POST http://localhost:3002/acquire \
-H "Content-Type: application/json" \
-d '{"role": "roleName", "workerId": "worker1"}'
  • release: POST /release
curl -X POST http://localhost:3002/release \
-H "Content-Type: application/json" \
-d '{"role": "roleName", "workerId": "worker1"}'
  • get all: GET /pool
curl -X GET http://localhost:3002/pool
  • release all: POST /release-all
curl -X POST http://localhost:3002/release-all

Running the Express API

npx ts-node express/express.up.ts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published