Browse Source

Fixes to stream position.

pull/531/head
Sebastian 6 years ago
parent
commit
40d8e1e57b
  1. 9
      backend/src/Squidex.Infrastructure.Azure/EventSourcing/StreamPosition.cs
  2. 17
      backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/StreamPosition.cs

9
backend/src/Squidex.Infrastructure.Azure/EventSourcing/StreamPosition.cs

@ -15,6 +15,8 @@ namespace Squidex.Infrastructure.EventSourcing
private static readonly ObjectPool<StringBuilder> StringBuilderPool =
new DefaultObjectPool<StringBuilder>(new StringBuilderPooledObjectPolicy());
public static readonly StreamPosition Empty = new StreamPosition();
public long Timestamp { get; }
public long CommitOffset { get; }
@ -59,13 +61,16 @@ namespace Squidex.Infrastructure.EventSourcing
{
var parts = position.Split('-');
return new StreamPosition(
if (parts.Length == 3)
{
return new StreamPosition(
long.Parse(parts[0]),
long.Parse(parts[1]),
long.Parse(parts[2]));
}
}
return new StreamPosition(0, -1, -1);
return Empty;
}
}
}

17
backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/StreamPosition.cs

@ -16,7 +16,9 @@ namespace Squidex.Infrastructure.EventSourcing
private static readonly ObjectPool<StringBuilder> StringBuilderPool =
new DefaultObjectPool<StringBuilder>(new StringBuilderPooledObjectPolicy());
private static readonly BsonTimestamp EmptyTimestamp = new BsonTimestamp(946681200, 0);
private static readonly BsonTimestamp EmptyTimestamp = new BsonTimestamp(0, 0);
public static readonly StreamPosition Empty = new StreamPosition(EmptyTimestamp, -1, -1);
public BsonTimestamp Timestamp { get; }
@ -64,13 +66,16 @@ namespace Squidex.Infrastructure.EventSourcing
{
var parts = position.Split('-');
return new StreamPosition(
new BsonTimestamp(int.Parse(parts[0]), int.Parse(parts[1])),
long.Parse(parts[2]),
long.Parse(parts[3]));
if (parts.Length == 4)
{
return new StreamPosition(
new BsonTimestamp(int.Parse(parts[0]), int.Parse(parts[1])),
long.Parse(parts[2]),
long.Parse(parts[3]));
}
}
return new StreamPosition(EmptyTimestamp, -1, -1);
return Empty;
}
}
}

Loading…
Cancel
Save