public MessageBusWriteStream(IProducer producer, string endPoint, string sequenceId, IConfiguration configuration) { _producer = producer; _endPoint = endPoint; _sequenceId = sequenceId; _configuration = configuration; _packetSize = producer.MaximumMessageSize; _packetsSent = 0; }
public Manager(IProducer<Action> workProducer, int threadCount) { _workComplete = new ManualResetEvent(false); _producer = workProducer; _workers = new Thread[threadCount]; _threadCount = threadCount; for (int i = 0; i < _workers.Length; i++) { _workers[i] = new Thread(GetWork) { Name = ("Worker " + i) }; } }
public Coordinator(CommandProcessorContext context, IProducer[] producers, int totalTasks, AutoResetEvent doneEvent) { Ensure.NotNull(context, "context"); Ensure.NotNull(producers, "producers"); Ensure.NotNull(doneEvent, "doneEvent"); _context = context; _producers = producers; _totalTasks = totalTasks; _doneEvent = doneEvent; }
async void connectButton_Click(object sender, EventArgs e) { connectButton.Enabled = false; disconnectButton.Enabled = true; var hostname = hostnameTextBox.Text; var port = Convert.ToInt32(portTextBox.Text); var connectionString = string.Format("{0}:{1}", hostname, port); var c = BeanstalkConnection.ConnectConsumerAsync(connectionString); var p = BeanstalkConnection.ConnectProducerAsync(connectionString); await Task.WhenAll(c, p); consumer = c.Result; producer = p.Result; }
public Coordinator(CommandProcessorContext context, IProducer[] producers, int totalEvents, AutoResetEvent createdEvent, AutoResetEvent doneEvent) { Ensure.NotNull(context, "context"); Ensure.NotNull(producers, "producers"); Ensure.NotNull(createdEvent, "createdEvent"); Ensure.NotNull(doneEvent, "doneEvent"); _context = context; _producers = producers; _totalEvents = totalEvents; _createdEvent = createdEvent; _doneEvent = doneEvent; _eventsForWriting = new ConcurrentVerificationEventQueue(); _eventsForVerification = new ConcurrentVerificationEventQueue(); }
public Consumer(IProducer producer) { this.producer = producer; }
public CreateProductRequestHandler(IProductRepository repository, IProducer producer) { _repository = repository; _producer = producer; }
public TracingProducer(ITracer tracer, IProducer <TKey, TValue> producer) { _tracer = tracer; _producer = producer; }
/// <summary> /// Returns the metadata associated with the specified stream, if the stream is persisted to a store. /// </summary> /// <typeparam name="T">The type of stream messages.</typeparam> /// <param name="source">The stream to retrieve metadata about.</param> /// <param name="metadata">Upon return, this parameter contains the metadata associated with the stream, or null if the stream is not persisted.</param> /// <returns>True if the stream is persisted to a store, false otherwise.</returns> public static bool TryGetMetadata <T>(IProducer <T> source, out PsiStreamMetadata metadata) { return(Store.TryGetMetadata(source.Out.Pipeline, source.Out.Name, out metadata)); }
public DependingProducer(object id, CustomProducer producer) { Key = id; Producer = producer; }
protected ArrayDataField(DataHolderDefinition dataHolder, string name, IGetterSetter accessor, MemberInfo mappedMember, INestedDataField parent, int length, IProducer arrProducer) : base(dataHolder, name, accessor, mappedMember, parent) { m_length = length; m_arrProducer = arrProducer; }
public PublishMessageToKafka(IProducer <int, string> kafkaProducer) { _kafkaProducer = kafkaProducer; }
/// <summary> /// Convert a stream to an <see cref="IObservable{T}"/>. /// </summary> /// <typeparam name="T">Type of messages for the source stream.</typeparam> /// <param name="stream">The source stream.</param> /// <param name="deliveryPolicy">An optional delivery policy.</param> /// <returns>Observable with elements from the source stream.</returns> public static IObservable <T> ToObservable <T>(this IProducer <T> stream, DeliveryPolicy deliveryPolicy = null) { return(new StreamObservable <T>(stream, deliveryPolicy)); }
public KafkaProducer(IKafkaConfig kafkaConfig) { Producer = new Producer <TKey, TValue>(kafkaConfig.ProducerConfig); }
/// <summary> /// Connnects a stream producer to a stream consumer. As a result, all messages in the stream will be routed to the consumer for processing. /// </summary> /// <remarks> /// This is an internal-only method which provides the option to allow connections between producers and consumers in running pipelines. /// </remarks> /// <typeparam name="TIn">The type of messages in the stream.</typeparam> /// <typeparam name="TC">The type of consumer.</typeparam> /// <param name="source">The source stream to subscribe to.</param> /// <param name="consumer">The consumer (subscriber).</param> /// <param name="allowWhileRunning">An optional flag to allow connections in running pipelines.</param> /// <param name="deliveryPolicy">An optional delivery policy.</param> /// <returns>Consumer.</returns> internal static TC PipeTo <TIn, TC>(this IProducer <TIn> source, TC consumer, bool allowWhileRunning, DeliveryPolicy deliveryPolicy = null) where TC : IConsumer <TIn> { source.Out.Subscribe(consumer.In, allowWhileRunning, deliveryPolicy ?? source.Out.Pipeline.DeliveryPolicy); return(consumer); }
/// <summary> /// Connnects a stream producer to a stream consumer. As a result, all messages in the stream will be routed to the consumer for processing. /// </summary> /// <typeparam name="TIn">The type of messages in the stream.</typeparam> /// <typeparam name="TC">The type of consumer.</typeparam> /// <param name="source">The source stream to subscribe to.</param> /// <param name="consumer">The consumer (subscriber).</param> /// <param name="deliveryPolicy">An optional delivery policy.</param> /// <returns>Consumer (subscriber).</returns> public static TC PipeTo <TIn, TC>(this IProducer <TIn> source, TC consumer, DeliveryPolicy deliveryPolicy = null) where TC : IConsumer <TIn> { return(PipeTo(source, consumer, false, deliveryPolicy)); }
public NetStreamProducer(string topic, IProducer <TKey, TMessage> producer, bool enableMessageTypeHeader = true) { _topic = topic; _producer = producer; _enableMessageTypeHeader = enableMessageTypeHeader; }
public Manager(IProducer<Action> workProducer) : this(workProducer, Environment.ProcessorCount) { }
/// <summary> /// Converts stream of enumerables of T to a stream of arrays of T, /// </summary> /// <typeparam name="T">The type of enumerable elements.</typeparam> /// <typeparam name="EnumerableT">The type of enumerable.</typeparam> /// <param name="source">The stream of enumerables of T.</param> /// <param name="deliveryPolicy">An optional delivery policy.</param> /// <returns>A stream of the converted array of T.</returns> public static IProducer <T[]> ToArray <T, EnumerableT>(this IProducer <EnumerableT> source, DeliveryPolicy deliveryPolicy = null) where EnumerableT : IEnumerable <T> { return(source.Select(s => s.ToArray(), deliveryPolicy)); }
/// <summary> /// Converts stream of dictionarys of TKey and TValue to a stream of collections of TValue /// </summary> /// <typeparam name="TKey">The type of dictionary keys.</typeparam> /// <typeparam name="TValue">The type of dictionary values.</typeparam> /// <param name="source">The stream of dictionarys of TKey and TValue.</param> /// <param name="deliveryPolicy">An optional delivery policy.</param> /// <returns>A stream of the converted collections of TValue.</returns> public static IProducer <Dictionary <TKey, TValue> .ValueCollection> Values <TKey, TValue>(this IProducer <Dictionary <TKey, TValue> > source, DeliveryPolicy deliveryPolicy = null) { return(source.Select(s => s.Values, deliveryPolicy)); }
protected NestedDataField(DataHolderDefinition dataHolder, string name, IGetterSetter accessor, MemberInfo mappedMember, IProducer producer, INestedDataField parent) : base(dataHolder, name, accessor, mappedMember, parent) { m_Producer = producer; }
/// <summary> /// Converts stream of dictionarys of 2d points to a stream of list of named points /// </summary> /// <typeparam name="TKey">The type of dictionary keys.</typeparam> /// <param name="source">The stream of dictionarys of 2d points.</param> /// <param name="deliveryPolicy">An optional delivery policy.</param> /// <returns>A stream of the converted list of named points.</returns> public static IProducer <List <Tuple <Point, string> > > ToScatterPoints2D <TKey>(this IProducer <Dictionary <TKey, Point2D> > source, DeliveryPolicy deliveryPolicy = null) { return(source.Select(d => d.Select(kvp => Tuple.Create(new Point(kvp.Value.X, kvp.Value.Y), kvp.Key.ToString())).ToList(), deliveryPolicy)); }
public NestedSimpleDataField(DataHolderDefinition dataHolder, string name, IGetterSetter accessor, MemberInfo mappedMember, IProducer producer, INestedDataField parent) : base(dataHolder, name, accessor, mappedMember, producer, parent) { }
/// <summary> /// Converts stream of dictionarys of rectangles to a stream of list of named rectangles /// </summary> /// <typeparam name="TKey">The type of dictionary keys.</typeparam> /// <param name="source">The stream of dictionarys of rectangles.</param> /// <param name="deliveryPolicy">An optional delivery policy.</param> /// <returns>A stream of the converted list of named rectangles.</returns> public static IProducer <List <Tuple <System.Drawing.Rectangle, string> > > ToScatterRectangle <TKey>(this IProducer <Dictionary <TKey, System.Drawing.Rectangle> > source, DeliveryPolicy deliveryPolicy = null) { return(source.Select(d => d.Select(kvp => Tuple.Create(kvp.Value, kvp.Key.ToString())).ToList(), deliveryPolicy)); }
/// <summary> /// Constructs a new market definition. The market definition represents additional market data which can be used for more advanced use cases /// </summary> /// <param name="marketDescription">The associated market descriptor</param> /// <param name="marketCacheProvider">The market cache provider used to retrieve name templates</param> /// <param name="sportId">The associated event sport identifier</param> /// <param name="producer">The producer which generated the market</param> /// <param name="specifiers">The associated market specifiers</param> internal MarketDefinition(IMarketDescription marketDescription, IMarketCacheProvider marketCacheProvider, URN sportId, IProducer producer, IReadOnlyDictionary <string, string> specifiers) { _marketDescription = marketDescription; _sportId = sportId; _producer = producer; _specifiers = specifiers; _marketCacheProvider = marketCacheProvider; }
public SequentialMergerBuilder AddInput(IProducer input) { Merger.ProcessList.Add(input); return(this); }
/// <summary> /// Writes the specified stream to a multi-stream store. /// </summary> /// <typeparam name="TIn">The type of messages in the stream.</typeparam> /// <param name="source">The source stream to write.</param> /// <param name="name">The name of the persisted stream.</param> /// <param name="writer">The store writer, created by e.g. <see cref="Store.Create(Pipeline, string, string, bool, KnownSerializers)"/>.</param> /// <param name="largeMessages">Indicates whether the stream contains large messages (typically >4k). If true, the messages will be written to the large message file.</param> /// <param name="deliveryPolicy">An optional delivery policy.</param> /// <returns>The input stream.</returns> public static IProducer <TIn> Write <TIn>(this IProducer <TIn> source, string name, Exporter writer, bool largeMessages = false, DeliveryPolicy deliveryPolicy = null) { writer.Write(source.Out, name, largeMessages, deliveryPolicy); return(source); }
public TestProducer(IProducer producer) => _producer = producer;
public ProducerWithLogging(IProducer producer) { this.producer = producer; }
/// <summary> /// Converts the source image to a different pixel format /// </summary> /// <param name="source">The source stream.</param> /// <param name="pixelFormat">The pixel format to convert to</param> /// <param name="deliveryPolicy">An optional delivery policy.</param> /// <returns>The resulting stream.</returns> public static IProducer <Shared <Image> > Convert(this IProducer <Shared <Image> > source, PixelFormat pixelFormat, DeliveryPolicy deliveryPolicy = null) { return(source.PipeTo(new ToPixelFormat(source.Out.Pipeline, pixelFormat), deliveryPolicy)); }
private static void Runner(IProducer<Action> producer, int threadCount) { var pm = new Manager(producer, threadCount); pm.Start(); pm.Join(); }
/// <summary> /// Converts an image to a different pixel format using the specified transformer /// </summary> /// <param name="source">Source image to compress</param> /// <param name="transformer">Method for converting an image sample</param> /// <param name="pixelFormat">Pixel format to use for converted image</param> /// <param name="deliveryPolicy">An optional delivery policy.</param> /// <returns>Returns a producer that generates the transformed images</returns> public static IProducer <Shared <Image> > Transform(this IProducer <Shared <Image> > source, TransformDelegate transformer, PixelFormat pixelFormat, DeliveryPolicy deliveryPolicy = null) { return(source.PipeTo(new ImageTransformer(source.Out.Pipeline, transformer, pixelFormat), deliveryPolicy)); }
async Task ConnectAsync() { cons = await BeanstalkConnection.ConnectConsumerAsync(connectionString); prod = await BeanstalkConnection.ConnectProducerAsync(connectionString); }
public ServiceImplWithDependency(IProducer <int> producer) { }
/// <summary> /// Writes the specified stream to a Annotation store. /// </summary> /// <typeparam name="TIn">The type of messages in the stream</typeparam> /// <param name="source">The source stream to write</param> /// <param name="name">The name of the persisted stream.</param> /// <param name="writer">The store writer, created by e.g. <see cref="Create(Pipeline, string, string, AnnotatedEventDefinition, bool)"/></param> /// <param name="policy">An optional delivery policy</param> /// <returns>The input stream</returns> public static IProducer <TIn> Write <TIn>(this IProducer <TIn> source, string name, AnnotationExporter writer, DeliveryPolicy policy = null) { writer.Write(source.Out, name, policy); return(source); }
internal KafkaProducer(IProducer <string, string> innerKafkaProducer) { _innerKafkaProducer = innerKafkaProducer; }
public Consumer(IProducer producer) { _producer = producer; }
public KafkaSender(IProducer <Null, byte[]> producer, string deviceId, RunnerConfiguration config, string topic) : base(deviceId, config) { this.producer = producer; this.topic = topic; }
public NestedArrayDataField(DataHolderDefinition dataHolder, string name, IGetterSetter accessor, MemberInfo mappedMember, IProducer producer, IProducer arrayProducer, int length, INestedDataField parent) : base(dataHolder, name, accessor, mappedMember, parent, length, arrayProducer) { m_Producer = producer; m_ArrayAccessors = new NestedArrayAccessor[m_length]; for (var i = 0; i < m_length; i++) { m_ArrayAccessors[i] = new NestedArrayAccessor(this, i); } }
public void Dispose() { Close(); _producer = null; }
public DependingProducer(object id, Type type) { Key = id; Producer = new DefaultProducer(type); }
/// <summary> /// Computes the linear velocity of a coordinate system. /// </summary> /// <param name="source">The source stream of coordinate systems.</param> /// <param name="deliveryPolicy">An optional delivery policy parameter.</param> /// <param name="name">An optional name for the stream operator.</param> /// <returns>A stream containing the linear velocity of the specified point.</returns> public static IProducer <LinearVelocity3D?> GetLinearVelocity3D(this IProducer <CoordinateSystem> source, DeliveryPolicy <CoordinateSystem> deliveryPolicy = null, string name = nameof(GetLinearVelocity3D)) => source.GetLinearVelocity3D(cs => cs?.Origin, deliveryPolicy, name);
public ObservingDataController(IProducer producer, IConsumer consumer) { _producer = producer; _consumer = consumer; }
public KafkaProducer(IEnumerable <KeyValuePair <string, string> > configuration) { _innerKafkaProducer = new ProducerBuilder <string, string>(configuration).Build(); }
public TaskCreator(InternalTopologyBuilder builder, IStreamConfig configuration, string threadId, IKafkaSupplier kafkaSupplier, IProducer <byte[], byte[]> producer) : base() { this.builder = builder; this.configuration = configuration; this.threadId = threadId; this.kafkaSupplier = kafkaSupplier; this.producer = producer; }
public DependingProducer(object id, Func<object> creator) { Key = id; Producer = new CustomProducer(creator); }
public KafkaClient(string bootstrapServers) { ConfigureProducer(bootstrapServers); _producer = new ProducerBuilder <string, string>(_producerConfig).Build(); ConfigureConsumer(bootstrapServers); }
public DataHolderDefinition(string name, Type type, string dependingField, DataHolderAttribute attribute) { m_name = name; m_DependingFieldName = dependingField; m_Attribute = attribute; m_Type = type; var dependingProducerTypes = type.GetCustomAttributes<DependingProducer>(); if (dependingProducerTypes.Length == 0) { m_dependingProducers = null; } else { m_dependingProducers = new Dictionary<object, IProducer>(); foreach (var prodAttr in dependingProducerTypes) { var key = prodAttr.Key; //var keyType = key.GetType(); //if (keyType.IsEnum) //{ // key = Convert.ChangeType(key, Enum.GetUnderlyingType(keyType)); //} //if (key is uint) //{ // key = (int)((uint)key); //} //else if (key is ulong) //{ // key = (long)((ulong)key); //} m_dependingProducers.Add(key, prodAttr.Producer); } } if (type.IsAbstract) { if (m_dependingProducers == null) { throw new DataHolderException( "Cannot define DataHolder because it's Type is abstract and it did not define depending Producers: {0}", type.FullName); } if (m_DependingFieldName == null) { throw new DataHolderException( "Cannot define DataHolder because it's Type is abstract and it did not define the DependsOnField in the DataHolderAttribute: {0}", type.FullName); } } else { m_defaultProducer = new DefaultProducer(type); } try { GetDataFields(type, Fields, null); if (type.IsAbstract && m_DependingField == null) { throw new DataHolderException( "Cannot define DataHolder because it's DependsOnField (\"{0}\"), as defined in the DataHolderAttribute, does not exist: {1}", m_DependingFieldName, type.FullName); } } catch (Exception e) { throw new DataHolderException(e, "Unable to create DataHolderDefinition for: " + name); } }
public void Initialize() { // Initializes the mock RequestListener ProducerListenerImpl producerListener = new ProducerListenerImpl( (_, __) => { }, (_, __, ___) => { }, (_, __, ___) => { }, (_, __, ___, ____) => { }, (_, __, ___) => { }, (_) => { return(false); }); _requestListener = new RequestListenerImpl( producerListener, (imageRequest, callerContext, requestId, isPrefetch) => { _onRequestStartInvocation = true; _internalImageRequest = imageRequest; _internalCallerContext = callerContext; _internalRequestId = requestId; _internalIsPrefetch = isPrefetch; }, (imageRequest, requestId, isPrefetch) => { _onRequestSuccessInvocation = true; _internalImageRequest = imageRequest; _internalRequestId = requestId; _internalIsPrefetch = isPrefetch; }, (imageRequest, requestId, exception, isPrefetch) => { _onRequestFailureInvocation = true; _internalImageRequest = imageRequest; _internalRequestId = requestId; _internalException = exception; _internalIsPrefetch = isPrefetch; }, (requestId) => { _onRequestCancellationInvocation = true; _internalRequestId = requestId; }); _result1 = new object(); _result2 = new object(); _result3 = new object(); _dataSubscriber1 = new MockDataSubscriber <object>(); _dataSubscriber2 = new MockDataSubscriber <object>(); _internalIsPrefetch = true; _settableProducerContext = new SettableProducerContext( IMAGE_REQUEST, REQUEST_ID, producerListener, CALLER_CONTEXT, RequestLevel.FULL_FETCH, IS_PREFETCH, true, Priority.HIGH); _producer = new ProducerImpl <object>( (consumer, _) => { _internalConsumer = consumer; }); _dataSource = ProducerToDataSourceAdapter <object> .Create( _producer, _settableProducerContext, _requestListener); Assert.IsTrue(_onRequestStartInvocation); Assert.AreSame(_internalImageRequest, IMAGE_REQUEST); Assert.AreSame(_internalCallerContext, CALLER_CONTEXT); Assert.AreSame(_internalRequestId, REQUEST_ID); Assert.IsFalse(_internalIsPrefetch); Assert.IsNotNull(_internalConsumer); _onRequestStartInvocation = false; _dataSource.Subscribe(_dataSubscriber1, CallerThreadExecutor.Instance); }