https://github.com/mesosphere-backup/connection-manager
Allows to manage connections inside the browser and order them in a queue by priority.
https://github.com/mesosphere-backup/connection-manager
browser connections manager pooling priority queue
Last synced: 5 months ago
JSON representation
Allows to manage connections inside the browser and order them in a queue by priority.
- Host: GitHub
- URL: https://github.com/mesosphere-backup/connection-manager
- Owner: mesosphere-backup
- License: apache-2.0
- Created: 2017-10-24T12:17:40.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T09:22:06.000Z (almost 3 years ago)
- Last Synced: 2024-11-09T00:54:43.073Z (11 months ago)
- Topics: browser, connections, manager, pooling, priority, queue
- Language: JavaScript
- Size: 121 KB
- Stars: 3
- Watchers: 7
- Forks: 1
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Connection Manager [](https://travis-ci.org/dcos-labs/connection-manager)
This package allows to manage connections inside the browser and order them in a queue by priority.
Browsers can open only a limited amount of connections so when you urgently need one there may not be a slot. This package solves the issue by providing a manager that enqueues all requested connections and priorities them accordingly.
## Usage
```javascript
import { XHRConnection, ConnectionEvent } from "@dcos/connections";
import ConnectionManager from "@dcos/connection-manager";const connection = new XHRConnection("http://127.0.0.1");
connection.on(ConnectionEvent.CLOSE, function(event) {
// doing something with event.target.response
});
ConnectionManager.enqueue(connection);
```Connection will be opened by the manager once there's a slot available.
## Connection types
At the moment `connection-manager` package exposes only one connection `XHRConnection` that wraps `XmlHttpRequest`
```javascript
const connection = new XHRConnection("http://127.0.0.1", {
method: "POST",
body: "{}",
contentType: "json"
});
```## Creating your own connection type
If you want to create your own connection type that will be compatible with the manager please extend `AbstractConnection`.
Have a look at `Connections/AbstractConnection.js` for more info.