Ejemplo n.º 1
0
        public async Task ExecuteAsync()
        {
            string url = @"http:\\localhost:8088";

            await using var context = new KSqlDBContext(url);

            var http = new HttpClientFactory(new Uri(url));

            restApiClient = new KSqlDbRestApiClient(http);

            await CreateOrReplaceStreamAsync();

            var statement = context.CreateTableStatement(MaterializedViewName)
                            .As <IoTSensor>("sensor_values")
                            .GroupBy(c => c.SensorId)
                            .Select(c => new { SensorId = c.Key, AvgValue = c.Avg(g => g.Value) });

            var query = statement.ToStatementString();

            var response = await statement.ExecuteStatementAsync();

            response = await InsertAsync(new IoTSensor { SensorId = "sensor-1", Value = 11 });

            await PullSensor(context);
        }
    public async Task ExecuteAsync()
    {
        string url = @"http:\\localhost:8088";

        await using var context = new KSqlDBContext(url);

        var http = new HttpClientFactory(new Uri(url));

        restApiClient = new KSqlDbRestApiClient(http);

        await CreateOrReplaceStreamAsync();

        var statement = context.CreateTableStatement(MaterializedViewName)
                        .As <IoTSensor>(StreamName)
                        .GroupBy(c => c.SensorId)
                        .WindowedBy(new TimeWindows(Duration.OfSeconds(5)).WithGracePeriod(Duration.OfHours(2)))
                        .Select(c => new { SensorId = c.Key, AvgValue = c.Avg(g => g.Value) });

        var response = await statement.ExecuteStatementAsync();

        var statementResponses = await response.ToStatementResponsesAsync();

        await Task.Delay(TimeSpan.FromSeconds(1));

        response = await InsertAsync(new IoTSensor { SensorId = "sensor-1", Value = 11 });
    }
Ejemplo n.º 3
0
    public Worker(IKSqlDBContextFactory <Program.IApplicationKSqlDbContext> contextFactory, Program.IApplicationKSqlDbContext context, IKSqlDbRestApiClient restApiClient, ILoggerFactory loggerFactory)
    {
        this.contextFactory = contextFactory ?? throw new ArgumentNullException(nameof(contextFactory));
        this.context        = context ?? throw new ArgumentNullException(nameof(context));
        this.restApiClient  = restApiClient ?? throw new ArgumentNullException(nameof(restApiClient));

        logger = loggerFactory.CreateLogger <Worker>();
    }
Ejemplo n.º 4
0
        public void Initialize()
        {
            var ksqlDbUrl = @"http:\\localhost:8088";

            var httpClientFactory = new HttpClientFactory(new Uri(ksqlDbUrl));

            restApiClient = new KSqlDbRestApiClient(httpClientFactory);
        }
Ejemplo n.º 5
0
    public void Initialize()
    {
        var ksqlDbUrl = @"http:\\localhost:8088";

        var httpClientFactory = new HttpClientFactory(new Uri(ksqlDbUrl));

        restApiClient = new KSqlDbRestApiClient(httpClientFactory);

        var contextOptions = new KSqlDBContextOptions(KSqlDbRestApiProvider.KsqlDbUrl)
        {
            ShouldPluralizeFromItemName = true
        };

        Context = new KSqlDBContext(contextOptions);
    }
Ejemplo n.º 6
0
 public Joins(IKSqlDbRestApiClient restApiClient, IKSqlDBContext context)
 {
     this.restApiClient = restApiClient ?? throw new ArgumentNullException(nameof(restApiClient));
     this.context       = context ?? throw new ArgumentNullException(nameof(context));
 }