0.0.2 • Published 4 years ago

apax-core v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Introduction

An auto proxy agent based on redis, in order to solve multi replicas problem.

Deploying proxy service on Linux servers and extention automatically based on Aliyun ECS are on the todo list.

简体中文

Preparation

An available redis server is needed.

Several linux servers with root authority is needed.

Installation

npm install apax-core --save

Node.js >= 8.0.0 required.

Example

const ApaxCore = require('apax-core')
const apaxCore = new ApaxCore({
  ips: ['192.168.0.1', '192.168.0.2'], // IPs with proxy service on the servers
  redis: 'redis://127.0.0.1:6379', // redis service
  serial: 30, // Serial duration, reuse the data if the apps restart in the duration
  expire: 30 // Expire duration of invalid ip, the ip won't be issued by getProxy in the duration if failed once
})

(async () => {
  const ip = await apaxCore.getProxy('https://example.com') // get an available ip
  try {
    await someRequests(ip) // do some requests
  } catch (e) {
    await apaxCore.fail('https://example.com', '192.168.0.1') // if a ip is blocked, call apaxCore.fail to shield it
  }
})()
0.0.2

4 years ago

0.0.1

4 years ago