Ejemplo n.º 1
0
 public TcpAsyncClient(byte[] readBuffer, byte[] sendBuffer,Log log)
 {
     this.log = new Log(new LogConfig());
     this.PacketBuf = readBuffer;
     this.SendBuffer = sendBuffer;
     this.PacketBufSize = 0;
     this.rc_event = new SocketAsyncEventArgs();
     this.rc_event.Completed += this.RecvEventCallback;
     this.m_processor = this.CreateStreamProcessor();
     this.Encryted = false;
 }
Ejemplo n.º 2
0
 public BaseClient(byte[] readBuffer, byte[] sendBuffer)
 {
     this.m_readBuffer        = readBuffer;
     this.m_sendBuffer        = sendBuffer;
     this.m_readBufEnd        = 0;
     this.rc_event            = new SocketAsyncEventArgs();
     this.rc_event.Completed += new EventHandler <SocketAsyncEventArgs>(this.RecvEventCallback);
     this.m_processor         = this.CreateStreamProcessor();
     this.m_encryted          = false;
     this.m_strict            = true;
 }
        /// <summary>
        /// Create instance of SaveToStorageProcessor with the given streamProcessor and filePath.
        /// </summary>
        /// <param name="streamProcessor"></param>
        /// <param name="filePath">Path of the file for the saving observable data.</param>
        /// <exception cref="ArgumentException">
        /// Thrown when file does not exists for <paramref name="filePath"/>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Thrown when <paramref name="streamProcessor"/> is null.
        /// </exception>
        public SaveToFileProcessor(IStreamProcessor <T> streamProcessor, string filePath)
        {
            _streamProcessor = streamProcessor ?? throw new ArgumentNullException($"The {nameof(streamProcessor)} can not be null.");

            if (!File.Exists(filePath))
            {
                using (File.Create(filePath)) { }
            }

            _filePath = filePath;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructs a StreamManager instance.
 /// </summary>
 /// <param name="streamProcessor">A platform-specific implementation of IStreamProcessor.</param>
 /// <param name="streamProperties">HTTP request properties for the stream.</param>
 /// <param name="config">An implementation of IBaseConfiguration.</param>
 /// <param name="clientEnvironment">A subclass of ClientEnvironment.</param>
 /// <param name="eventSourceCreator">Null in normal usage; pass a non-null delegate if you
 /// are in a unit test and want to mock out the event source.</param>
 public StreamManager(IStreamProcessor streamProcessor, StreamProperties streamProperties,
                      IBaseConfiguration config, ClientEnvironment clientEnvironment,
                      EventSourceCreator eventSourceCreator)
 {
     _streamProcessor   = streamProcessor;
     _streamProperties  = streamProperties;
     _config            = config;
     _clientEnvironment = clientEnvironment;
     _esCreator         = eventSourceCreator ?? DefaultEventSourceCreator;
     _initTask          = new TaskCompletionSource <bool>();
     _backOff           = new EventSource.ExponentialBackoffWithDecorrelation(_config.ReconnectTime, TimeSpan.FromMilliseconds(30000));
 }
Ejemplo n.º 5
0
        public OCStreamer(bool multiThread = false, StreamAlgorithm algorithm = StreamAlgorithm.GZip)
        {
            _algorithm = algorithm;

            if (multiThread)
            {
                _streamProcessor = new StreamAsyncProcessor(algorithm);
            }
            else
            {
                _streamProcessor = new StreamSyncProcessor(algorithm);
            }
        }
 public StreamManagerTest()
 {
     _mockEventSource = new Mock <IEventSource>();
     _mockEventSource.Setup(es => es.StartAsync()).Returns(Task.CompletedTask);
     _eventSource        = _mockEventSource.Object;
     _eventSourceCreator = new StubEventSourceCreator(_eventSource);
     _config             = new SimpleConfiguration
     {
         SdkKey = SdkKey
     };
     _mockStreamProcessor = new Mock <IStreamProcessor>();
     _streamProcessor     = _mockStreamProcessor.Object;
     _streamProperties    = new StreamProperties(StreamUri, HttpMethod.Get, null);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Adds/Replaces the processor associated with the MessageType
        /// </summary>
        /// <param name="messageType">MessageType that will trigger the processor</param>
        /// <param name="streamProcessor">The processor which will be invoked when the MessageType is received</param>
        /// <returns></returns>
        public SkyNoodleConsumer WithStreamProcessor(string messageType, IStreamProcessor streamProcessor)
        {
            if (_streamProcessors.ContainsKey(messageType))
            {
                _streamProcessors[messageType] = new List <IStreamProcessor>()
                {
                    streamProcessor
                };
                return(this);
            }

            _streamProcessors.Add(messageType, new List <IStreamProcessor> {
                streamProcessor
            });
            return(this);
        }
Ejemplo n.º 8
0
 public void Add(IStreamProcessor processor)
 {
     processors.Add(processor);
 }
Ejemplo n.º 9
0
 public SampledStreamController(ILogger <SampledStreamController> logger, IConfiguration configuration, IStreamProcessor sampleStreamProcessor)
 {
     _logger = logger;
     SampleStreamProcessor     = sampleStreamProcessor;
     twitterCredentialsOptions = configuration.GetSection(TwitterCredentialsOptions.TwitterCredentials).Get <TwitterCredentialsOptions>();
 }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            var environment = "Development";

            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json", true, true)
                         .AddJsonFile($"appsettings.{environment}.json", true, true)
                         .Build();

            var awsConfig = config.GetSection("Aws");

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.File("L:/LogFiles/Tinamous.MeasurementsProcessor/{Date}.txt")
                         .WriteTo.Console()
                         .CreateLogger();

            var     mapperConfiguration = AutoMapperConfiguration.Configure();
            IMapper mapper = mapperConfiguration.CreateMapper();

            IServiceCollection serviceCollection = new ServiceCollection()
                                                   .AddLogging()
                                                   .AddTransient <IBusFactory, BusFactory>()
                                                   .AddTransient <IMembershipService, MembershipService>()
                                                   .AddTransient <IHeartbeatService, HeartbeatService>()
                                                   .AddTransient <IAwsClientFactory, AwsClientFactory>()
                                                   .AddTransient <IAwsKinesisFactory, AwsKinesisFactory>()
                                                   .AddTransient <IRecordProcessorFactory, RecordProcessorFactory>()
                                                   .AddTransient <ICheckpointRepository, CheckpointRepository>()
                                                   .AddTransient <IMeasurementUserPropertiesRepository, MeasurementUserPropertiesRepository>()
                                                   .AddTransient <IMembershipService, MembershipService>()
                                                   //.AddTransient<>()
                                                   .AddSingleton <IMapper>(mapper)

                                                   .AddTransient <IStreamProcessor, StreamProcessor>()
                                                   .Configure <MessagingSettings>(config.GetSection("Messaging"))
                                                   .Configure <AwsSettings>(config.GetSection("Aws"))
                                                   .Configure <ServerSettings>(config.GetSection("Service"));


            serviceCollection.AddLogging(configure => configure.AddSerilog());
            ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
            var             logger          = serviceProvider.GetService <ILogger <Program> >();

            serviceCollection.AddSingleton <Microsoft.Extensions.Logging.ILogger>(logger);

            serviceProvider = serviceCollection.BuildServiceProvider();

            //serviceProvider
            //    .GetService<ILoggingBuilder>()
            //    .AddConsole();

            using (IStreamProcessor streamProcessor = serviceProvider.GetService <IStreamProcessor>())
            {
                streamProcessor.CreateTables().Wait();
                streamProcessor.CreateKinesisStreamsAsync().Wait();
                streamProcessor.SetupProcessors();
                streamProcessor.SetupEventWatchers();

                Console.WriteLine("Hello World!");
                Console.ReadLine();
            }
        }