Giter Site home page Giter Site logo

geyser's Introduction

geyser

提供以WebSocket为通讯协议的咨询式速率限制器.

Quickstart

docker run \
  --detach \
  --publish 8080:8080 \
  blackglory/geyser

Install

从源代码运行

git clone https://github.com/BlackGlory/geyser
cd geyser
yarn install
yarn build
yarn bundle
yarn --silent start

从源代码构建

git clone https://github.com/BlackGlory/geyser
cd geyser
yarn install
yarn docker:build

Recipes

docker-compose.yml

version: '3.8'

services:
  geyser:
    image: 'blackglory/geyser'
    restart: always
    volumes:
      - 'geyser-data:/data'
    ports:
      - '8080:8080'

volumes:
  geyser-data:

API

interface IRateLimiterConfig extends JSONObject {
  duration: number | null
  limit: number | null
}

interface IAPI {
  getAllRateLimiterIds(): string[]

  getRateLimiter(rateLimiterId: string): IRateLimiterConfig | null
  setRateLimiter(rateLimiterId: string, config: IRateLimiterConfig): null
  removeRateLimiter(rateLimiterId: string): null

  /**
   * 重置速率限制器的状态.
   * 
   * @throws {RateLimiterNotFound}
   */
  resetRateLimiter(rateLimiterId: string): null

  /**
   * @throws {RateLimiterNotFound}
   */
  acquireToken(rateLimiterId: string): null
}

/**
 * 速率限制器在未经配置的情况下, 相当于不存在.
 */
class RateLimiterNotFound extends CustomError {}

环境变量

GEYSER_HOST, GEYSER_PORT

通过环境变量GEYSER_HOSTGEYSER_PORT决定服务器监听的地址和端口, 默认值为localhost8080.

GEYSER_WS_HEARTBEAT_INTERVAL

通过环境变量GEYSER_WS_HEARTBEAT_INTERVAL可以设置WS心跳包(ping帧)的发送间隔, 单位为毫秒. 在默认情况下, 服务不会发送心跳包, 半开连接的检测依赖于服务端和客户端的运行平台的TCP Keepalive配置.

GEYSER_WS_HEARTBEAT_INTERVAL大于零时, 服务会通过WS的ping帧按间隔发送心跳包.

客户端

geyser's People

Contributors

blackglory avatar dependabot[bot] avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.