private Event CreateStreamMetadataEvent() { var eventId = Guid.NewGuid(); var acl = new StreamAcl( readRole: SystemRoles.Admins, writeRole: SystemRoles.Admins, deleteRole: SystemRoles.Admins, metaReadRole: SystemRoles.All, metaWriteRole: SystemRoles.Admins); var metadata = new StreamMetadata(maxCount: 2, maxAge: null, cacheControl: null, acl: acl); var dataBytes = metadata.ToJsonBytes(); return new Event(eventId, SystemEventTypes.StreamMetadata, isJson: true, data: dataBytes, metadata: null); }
private Event CreateStreamMetadataEvent(int? tb) { var eventId = Guid.NewGuid(); var acl = new StreamAcl( readRole: SystemRoles.Admins, writeRole: SystemRoles.Admins, deleteRole: SystemRoles.Admins, metaReadRole: SystemRoles.Admins, metaWriteRole: SystemRoles.Admins); var metadata = new StreamMetadata(cacheControl: null, truncateBefore: tb, acl: acl); var dataBytes = metadata.ToJsonBytes(); return new Event(eventId, SystemEventTypes.StreamMetadata, isJson: true, data: dataBytes, metadata: null); }
public ReadAllEventsBackwardCompleted(Guid correlationId, ReadAllResult result, string error, ResolvedEvent[] events, StreamMetadata streamMetadata, bool isCachePublic, int maxCount, TFPos currentPos, TFPos nextPos, TFPos prevPos, long tfLastCommitPosition) { Ensure.NotNull(events, "events"); CorrelationId = correlationId; Result = result; Error = error; Events = events; StreamMetadata = streamMetadata; IsCachePublic = isCachePublic; MaxCount = maxCount; CurrentPos = currentPos; NextPos = nextPos; PrevPos = prevPos; TfLastCommitPosition = tfLastCommitPosition; }
public ReadStreamEventsBackwardCompleted(Guid correlationId, string eventStreamId, int fromEventNumber, int maxCount, ReadStreamResult result, ResolvedEvent[] events, StreamMetadata streamMetadata, bool isCachePublic, string error, int nextEventNumber, int lastEventNumber, bool isEndOfStream, long tfLastCommitPosition) { Ensure.NotNull(events, "events"); if (result != ReadStreamResult.Success) { Ensure.Equal(nextEventNumber, -1, "nextEventNumber"); Ensure.Equal(isEndOfStream, true, "isEndOfStream"); } CorrelationId = correlationId; EventStreamId = eventStreamId; FromEventNumber = fromEventNumber; MaxCount = maxCount; Result = result; Events = events; StreamMetadata = streamMetadata; IsCachePublic = isCachePublic; Error = error; NextEventNumber = nextEventNumber; LastEventNumber = lastEventNumber; IsEndOfStream = isEndOfStream; TfLastCommitPosition = tfLastCommitPosition; }
public ReadEventCompleted(Guid correlationId, string eventStreamId, ReadEventResult result, ResolvedEvent record, StreamMetadata streamMetadata, bool isCachePublic, string error) { Ensure.NotNullOrEmpty(eventStreamId, "eventStreamId"); if (result == ReadEventResult.Success) Ensure.NotNull(record.Event, "record.Event"); CorrelationId = correlationId; EventStreamId = eventStreamId; Result = result; Record = record; StreamMetadata = streamMetadata; IsCachePublic = isCachePublic; Error = error; }
private static int? GetCacheSeconds(StreamMetadata metadata) { return metadata != null && metadata.CacheControl.HasValue ? (int) metadata.CacheControl.Value.TotalSeconds : (int?) null; }
public static Rec Prepare(int transaction, string stream, string eventType = null, DateTime? timestamp = null, StreamMetadata metadata = null) { return new Rec(RecType.Prepare, transaction, stream, eventType, timestamp, metadata); }
public Rec(RecType type, int transaction, string streamId, string eventType, DateTime? timestamp, StreamMetadata metadata = null) { Ensure.NotNullOrEmpty(streamId, "streamId"); Ensure.Nonnegative(transaction, "transaction"); Type = type; Id = Guid.NewGuid(); Transaction = transaction; StreamId = streamId; EventType = eventType ?? string.Empty; TimeStamp = timestamp ?? DateTime.UtcNow; Metadata = metadata; }
private static bool IsCachePublic(string streamId, StreamMetadata metadata) { if (SystemStreams.IsMetastream(streamId)) return false; // we don't have enough info here for metastreams var isSystem = SystemStreams.IsSystemStream(streamId); var role = (metadata == null || metadata.Acl == null) ? null : metadata.Acl.ReadRole; return isSystem ? (role == SystemUserGroups.All) : (role == null || role == SystemUserGroups.All); }