Skip to content

Commit

Permalink
Optimize filter for changestreams for iec60870 server protocols.
Browse files Browse the repository at this point in the history
  • Loading branch information
riclolsen committed May 22, 2024
1 parent 2b82ade commit e8025a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib60870.netcore/iec101server/MongoChangeStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ static async void ProcessMongoCS(JSONSCADAConfig jsConfig)
throw new Exception("Error on connection " + jsConfig.mongoConnectionString);

Log("MongoDB CMD CS - Start listening for realtime data updates via changestream...");
// observe updates and replaces, avoid updates with sourceDataUpdateField (those are handled by cs_data_processor.js)
var filter = "{ $or: [{ $and:[{ 'updateDescription.updatedFields.sourceDataUpdate': { $exists: false } },{ operationType: 'update' }] }, { operationType: 'replace'}] }";
// observe updates and replaces, avoid updates with sourceDataUpdateField (those are handled by cs_data_processor.js), require protocolDestinations not null
var filter = "{ $or: [{ $and:[{ 'fullDocument.protocolDestinations': { $ne: null } },{ 'updateDescription.updatedFields.sourceDataUpdate': { $exists: false } },{ operationType: 'update' }] }, { operationType: 'replace'}] }";

var pipeline =
new EmptyPipelineDefinition<ChangeStreamDocument<rtData
Expand Down
4 changes: 2 additions & 2 deletions src/lib60870.netcore/iec104server/MongoChangeStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ static async void ProcessMongoCS(JSONSCADAConfig jsConfig)
throw new Exception("Error on connection " + jsConfig.mongoConnectionString);

Log("MongoDB CMD CS - Start listening for realtime data updates via changestream...");
// observe updates and replaces, avoid updates with sourceDataUpdateField (those are handled by cs_data_processor.js)
var filter = "{ $or: [{ $and:[{ 'updateDescription.updatedFields.sourceDataUpdate': { $exists: false } },{ operationType: 'update' }] }, { operationType: 'replace'}] }";
// observe updates and replaces, avoid updates with sourceDataUpdateField (those are handled by cs_data_processor.js), require protocolDestinations not null
var filter = "{ $or: [{ $and:[{ 'fullDocument.protocolDestinations': { $ne: null } },{ 'updateDescription.updatedFields.sourceDataUpdate': { $exists: false } },{ operationType: 'update' }] }, { operationType: 'replace'}] }";

var pipeline =
new EmptyPipelineDefinition<ChangeStreamDocument<rtData
Expand Down

0 comments on commit e8025a3

Please sign in to comment.