@@ -19,6 +19,7 @@ let ydocUpdateCallback = env.getConf('ydoc-update-callback')
19
19
if ( ydocUpdateCallback != null && ydocUpdateCallback . slice ( - 1 ) !== '/' ) {
20
20
ydocUpdateCallback += '/'
21
21
}
22
+ const WORKER_DISABLED = env . getConf ( 'y-worker-disabled' ) === 'true'
22
23
23
24
/**
24
25
* @param {string } a
@@ -117,20 +118,25 @@ export class Api {
117
118
this . redisWorkerGroupName = this . prefix + ':worker'
118
119
this . workerSetName = `${ this . prefix } :worker:${ this . consumername } :idset`
119
120
this . _destroyed = false
121
+
122
+ const addScript = WORKER_DISABLED
123
+ ? 'redis.call("XADD", KEYS[1], "*", "m", ARGV[1])'
124
+ : `
125
+ if redis.call("EXISTS", KEYS[1]) == 0 then
126
+ redis.call("XADD", "${ this . redisWorkerStreamName } ", "*", "compact", KEYS[1])
127
+ elseif redis.call("XLEN", KEYS[1]) > 100 then
128
+ redis.call("SADD", "${ this . prefix } :worker:checklist", KEYS[1])
129
+ end
130
+ redis.call("XADD", KEYS[1], "*", "m", ARGV[1])
131
+ `
132
+
120
133
this . redis = redis . createClient ( {
121
134
url,
122
135
// scripting: https://github.com/redis/node-redis/#lua-scripts
123
136
scripts : {
124
137
addMessage : redis . defineScript ( {
125
138
NUMBER_OF_KEYS : 1 ,
126
- SCRIPT : `
127
- -- if redis.call("EXISTS", KEYS[1]) == 0 then
128
- -- redis.call("XADD", "${ this . redisWorkerStreamName } ", "*", "compact", KEYS[1])
129
- -- elseif redis.call("XLEN", KEYS[1]) > 100 then
130
- -- redis.call("SADD", "${ this . prefix } :worker:checklist", KEYS[1])
131
- -- end
132
- redis.call("XADD", KEYS[1], "*", "m", ARGV[1])
133
- ` ,
139
+ SCRIPT : addScript ,
134
140
/**
135
141
* @param {string } key
136
142
* @param {Buffer } message
0 commit comments