Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await new Promise(resolve => setTimeout(resolve, options.delay!))
}
for (const commit of commitPartials) {
const {
aggregateVersion = 1,
aggregateType = defaults.aggregateType,
aggregateKey = defaults.aggregateKey,
timestamp,
events,
} = commit
if (!aggregateType || !aggregateKey || !events) {
throw new Error(`Missing commit data ${inspect(commit)}`)
}
yield new Commit({
aggregateType,
aggregateKey,
aggregateVersion,
timestamp,
events: events.map((event: object) => ({version: 1, ...event})),
})
}
if (options.neverEnding) {
await new Promise(resolve => {
//
})
}
}
export default commitYielder
public async commit(commit: Commit) {
try {
await this.dynamodb
.putItem({
TableName: this.tableName,
Item: await utils.marshallCommit(commit),
ConditionExpression: 'attribute_not_exists(v)',
ReturnValues: 'NONE',
})
.promise()
} catch (error) {
if (error.code === 'ConditionalCheckFailedException') {
throw new VersionConflictError(
`${commit.aggregateType}[${
commit.aggregateKey
}] already has a version ${commit.aggregateVersion} commit`
)
}
throw error
}
}
if (!snapshotJSON) {
return null
}
const {
version,
state,
timestamp: timestampString,
compatibilityChecksum,
} = JSON.parse(snapshotJSON as string)
return {
version,
state,
timestamp: coreutils.toTimestamp(timestampString),
compatibilityChecksum,
}
} catch (error) {
if (error.code !== 'NoSuchKey') {
throw error
}
return null
}
}
const data = snapshot.data()
if (!data) {
return null
}
const {
version,
state,
timestamp: timestampString,
compatibilityChecksum,
} = JSON.parse((await zipper.unzip(data.data)) as string)
return {
version,
state,
timestamp: utils.toTimestamp(timestampString),
compatibilityChecksum,
}
} catch (e) {
return null
}
}
public deleteSnapshots(): Promise {
!outputCommits.find(outputCommit =>
Commit.hasSameKey(outputCommit, commit)
)
}
) {
const {
authenticateClient: verifyClient,
port = 80,
chronologicalGroups = ['default'],
...storePollerParams
} = params
this.wss = new WebSocketServer({verifyClient, port})
this.wss.on('connection', this.onClientConnected.bind(this))
this.chronologicalGroups = chronologicalGroups
for (const chronologicalGroup of chronologicalGroups) {
this.storePollers.push(
new StorePoller({
...storePollerParams,
processCommit: this.processCommit.bind(this),
})
)
}
this.debug = debug('DDES.EventStreamer.Server')
}