예제 #1
0
        /// <summary>
        /// Writes the specified stream to this multi-stream store.
        /// </summary>
        /// <param name="source">The source stream to write.</param>
        /// <param name="metadata">The stream metadata of the stream.</param>
        /// <param name="deliveryPolicy">An optional delivery policy.</param>
        internal void Write(Emitter <Message <JToken> > source, JsonStreamMetadata metadata, DeliveryPolicy deliveryPolicy = null)
        {
            var mergeInput = this.merger.Add(metadata.Name); // this checks for duplicates

            this.writer.OpenStream(metadata);
            Operators.PipeTo(source, mergeInput, deliveryPolicy);
        }
예제 #2
0
        /// <summary>
        /// Opens the stream for the specified stream.
        /// </summary>
        /// <param name="metadata">The metadata of the stream.</param>
        /// <returns>The stream metadata.</returns>
        public JsonStreamMetadata OpenStream(JsonStreamMetadata metadata)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }

            return(this.OpenStream(metadata.Id, metadata.Name, metadata.TypeName));
        }
예제 #3
0
        /// <summary>
        /// Opens the stream for the specified stream
        /// </summary>
        /// <param name="metadata">The metadata of the stream.</param>
        /// <returns>true if the stream was opened; otherwise false.</returns>
        public bool OpenStream(JsonStreamMetadata metadata)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }

            if (this.enabledStreams.Contains(metadata.Id))
            {
                return(false);
            }

            this.enabledStreams.Add(metadata.Id);
            return(true);
        }
예제 #4
0
        /// <summary>
        /// Opens the stream for the specified stream.
        /// </summary>
        /// <param name="streamId">The stream id.</param>
        /// <param name="streamName">The stream name.</param>
        /// <param name="typeName">The stream type name.</param>
        /// <returns>The stream metadata.</returns>
        public JsonStreamMetadata OpenStream(int streamId, string streamName, string typeName)
        {
            if (this.catalog.ContainsKey(streamId))
            {
                throw new InvalidOperationException($"The stream id {streamId} has already been registered with this writer.");
            }

            var metadata = new JsonStreamMetadata()
            {
                Id = streamId, Name = streamName, PartitionName = this.Name, PartitionPath = this.Path, TypeName = typeName
            };

            this.catalog[metadata.Id] = metadata;
            this.WriteCatalog(); // ensure catalog is up to date even if crashing later
            return(metadata);
        }