Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
- Added `LedgerMetrics` class to record write latency and total events for ledger operations. - Created comprehensive tests for Ruby packages endpoints, covering scenarios for missing inventory, successful retrieval, and identifier handling. - Introduced `TestSurfaceSecretsScope` for managing environment variables during tests. - Developed `ProvenanceMongoExtensions` for attaching DSSE provenance and trust information to event documents. - Implemented `EventProvenanceWriter` and `EventWriter` classes for managing event provenance in MongoDB. - Established MongoDB indexes for efficient querying of events based on provenance and trust. - Added models and JSON parsing logic for DSSE provenance and trust information.
26 lines
665 B
C#
26 lines
665 B
C#
using MongoDB.Bson;
|
|
using MongoDB.Driver;
|
|
using StellaOps.Provenance.Mongo;
|
|
|
|
namespace StellaOps.Events.Mongo;
|
|
|
|
public sealed class EventWriter
|
|
{
|
|
private readonly IMongoCollection<BsonDocument> _events;
|
|
|
|
public EventWriter(IMongoDatabase db, string collectionName = "events")
|
|
{
|
|
_events = db.GetCollection<BsonDocument>(collectionName);
|
|
}
|
|
|
|
public async Task AppendEventAsync(
|
|
BsonDocument eventDoc,
|
|
DsseProvenance dsse,
|
|
TrustInfo trust,
|
|
CancellationToken ct = default)
|
|
{
|
|
eventDoc.AttachDsseProvenance(dsse, trust);
|
|
await _events.InsertOneAsync(eventDoc, cancellationToken: ct);
|
|
}
|
|
}
|