@@ -55,6 +55,57 @@ async function createIssueOnAllRepos (org) {
5555
5656Pass ` { throttle: { enabled: false } } ` to disable this plugin.
5757
58+ ### Clustering
59+
60+ Enabling Clustering support ensures that your application will not go over rate limits ** across Octokit instances and across Nodejs processes** .
61+
62+ First install either ` redis ` or ` ioredis ` :
63+ ```
64+ # NodeRedis (https://github.com/NodeRedis/node_redis)
65+ npm install --save redis
66+
67+ # or ioredis (https://github.com/luin/ioredis)
68+ npm install --save ioredis
69+ ```
70+
71+ Then in your application:
72+ ``` js
73+ const Bottleneck = require (' bottleneck' )
74+ const Redis = require (' redis' )
75+
76+ const client = Redis .createClient ({ /* options */ })
77+ const connection = new Bottleneck.RedisConnection ({ client })
78+ connection .on (' error' , err => console .error (err))
79+
80+ const octokit = new Octokit ({
81+ throttle: {
82+ onAbuseLimit : (retryAfter , options ) => { /* ... */ },
83+ onRateLimit : (retryAfter , options ) => { /* ... */ },
84+
85+ // The Bottleneck connection object
86+ connection,
87+
88+ // A "throttling ID". All octokit instances with the same ID
89+ // using the same Redis server will share the throttling.
90+ id: ' my-super-app' ,
91+
92+ // Otherwise the plugin uses a lighter version of Bottleneck without Redis support
93+ Bottleneck
94+ }
95+ })
96+
97+ // To close the connection and allow your application to exit cleanly:
98+ await connection .disconnect ()
99+ ```
100+
101+ To use the ` ioredis ` library instead:
102+ ``` js
103+ const Redis = require (' ioredis' )
104+ const client = new Redis ({ /* options */ })
105+ const connection = new Bottleneck.IORedisConnection ({ client })
106+ connection .on (' error' , err => console .error (err))
107+ ```
108+
58109## LICENSE
59110
60111[ MIT] ( LICENSE )
0 commit comments