@teamvibe/poller 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/session-store.js +11 -18
- package/package.json +1 -1
package/dist/session-store.js
CHANGED
|
@@ -106,33 +106,26 @@ export async function acquireSessionLock(threadId, workspacePath) {
|
|
|
106
106
|
// Session is idle/waiting - try to acquire lock
|
|
107
107
|
const newLockToken = generateLockToken();
|
|
108
108
|
const now = Date.now();
|
|
109
|
-
const hasOldToken = existingSession.lock_token != null;
|
|
110
|
-
const conditionExpression = hasOldToken
|
|
111
|
-
? '#status IN (:idle, :waiting) AND (lock_token = :oldToken OR attribute_not_exists(lock_token))'
|
|
112
|
-
: '#status IN (:idle, :waiting) AND attribute_not_exists(lock_token)';
|
|
113
|
-
const expressionValues = {
|
|
114
|
-
':processing': 'processing',
|
|
115
|
-
':idle': 'idle',
|
|
116
|
-
':waiting': 'waiting_for_input',
|
|
117
|
-
':newToken': newLockToken,
|
|
118
|
-
':now': now,
|
|
119
|
-
':one': 1,
|
|
120
|
-
':ttl': calculateTTL(),
|
|
121
|
-
};
|
|
122
|
-
if (hasOldToken) {
|
|
123
|
-
expressionValues[':oldToken'] = existingSession.lock_token;
|
|
124
|
-
}
|
|
125
109
|
try {
|
|
126
110
|
await createDocClient().send(new UpdateCommand({
|
|
127
111
|
TableName: getTableName(),
|
|
128
112
|
Key: buildKey(threadId),
|
|
129
113
|
UpdateExpression: 'SET #status = :processing, lock_token = :newToken, last_activity = :now, message_count = message_count + :one, #ttl = :ttl',
|
|
130
|
-
ConditionExpression:
|
|
114
|
+
ConditionExpression: '#status IN (:idle, :waiting) AND (lock_token = :oldToken OR attribute_not_exists(lock_token))',
|
|
131
115
|
ExpressionAttributeNames: {
|
|
132
116
|
'#status': 'status',
|
|
133
117
|
'#ttl': 'ttl',
|
|
134
118
|
},
|
|
135
|
-
ExpressionAttributeValues:
|
|
119
|
+
ExpressionAttributeValues: {
|
|
120
|
+
':processing': 'processing',
|
|
121
|
+
':idle': 'idle',
|
|
122
|
+
':waiting': 'waiting_for_input',
|
|
123
|
+
':newToken': newLockToken,
|
|
124
|
+
':oldToken': existingSession.lock_token,
|
|
125
|
+
':now': now,
|
|
126
|
+
':one': 1,
|
|
127
|
+
':ttl': calculateTTL(),
|
|
128
|
+
},
|
|
136
129
|
}));
|
|
137
130
|
const updatedSession = {
|
|
138
131
|
...existingSession,
|