Exemplo n.º 1
0
    private static async Task SubscribeAsync(IKSqlDBContext context)
    {
        var cts = new CancellationTokenSource();

        try
        {
            var subscription = await context.CreateQueryStream <Movie>()
                               .SubscribeOn(ThreadPoolScheduler.Instance)
                               .ObserveOn(TaskPoolScheduler.Default)
                               .SubscribeAsync(onNext: movie =>
            {
                Console.WriteLine($"{nameof(Movie)}: {movie.Id} - {movie.Title} - {movie.RowTime}");
                Console.WriteLine();
            }, onError: error => { Console.WriteLine($"SubscribeAsync Exception: {error.Message}"); },
                                               onCompleted: () => Console.WriteLine("SubscribeAsync Completed"), cts.Token);

            Console.WriteLine($"Query id: {subscription.QueryId}");
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }

        await Task.Delay(9000, cts.Token);

        cts.Cancel();
    }
Exemplo n.º 2
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>();
    }
Exemplo n.º 3
0
 public Joins(IKSqlDbRestApiClient restApiClient, IKSqlDBContext context)
 {
     this.restApiClient = restApiClient ?? throw new ArgumentNullException(nameof(restApiClient));
     this.context       = context ?? throw new ArgumentNullException(nameof(context));
 }
 public KSqlDb(IKSqlDBContext context)
 {
     this.context = context;
 }
Exemplo n.º 5
0
 private static void Between(IKSqlDBContext context)
 {
     var ksql = context.CreateQueryStream <Tweet>().Where(c => c.Id.Between(1, 5))
                .ToQueryString();
 }