private static async Task <IAsyncChannel> NullProcessorAsyncMethod(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, AsyncProcessDelegate asyncNext, CancellationToken cancellationToken) { IAsyncChannel newAsyncChannel; if ((object)asyncContext == null) { throw new ArgumentNullException(nameof(asyncContext)); } if ((object)configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if ((object)asyncChannel == null) { throw new ArgumentNullException(nameof(asyncChannel)); } await StdOut.WriteLineAsync(string.Format("{1} (before next) processor: '{0}'", nameof(NullProcessor), nameof(NullProcessorAsyncMethod))); if ((object)asyncNext != null) { newAsyncChannel = await asyncNext(asyncContext, configuration, asyncChannel, cancellationToken); } else { newAsyncChannel = asyncChannel; } await StdOut.WriteLineAsync(string.Format("{1} (after next) processor: '{0}'", nameof(NullProcessor), nameof(NullProcessorAsyncMethod))); return(newAsyncChannel); }
protected override async Task ConsumeAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, CancellationToken cancellationToken) { IAsyncEnumerable <IRecord> records; if ((object)asyncContext == null) { throw new ArgumentNullException(nameof(asyncContext)); } if ((object)configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if ((object)asyncChannel == null) { throw new ArgumentNullException(nameof(asyncChannel)); } this.AssertValidConfiguration(); records = asyncChannel.Records; if ((object)records == null) { throw new SyncPremException(nameof(records)); } var payloads = asyncChannel.Records.Select(p => p.Payload); await this.TextualWriter.WriteRecordsAsync(payloads, cancellationToken); }
protected override async Task ConsumeAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, CancellationToken cancellationToken) { IAsyncEnumerable <IRecord> records; if ((object)asyncContext == null) { throw new ArgumentNullException(nameof(asyncContext)); } if ((object)configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if ((object)asyncChannel == null) { throw new ArgumentNullException(nameof(asyncChannel)); } this.AssertValidConfiguration(); RestfulWebApiConnectorSpecificConfiguration fsConfig = this.Configuration.StageSpecificConfiguration; records = asyncChannel.Records; if ((object)records == null) { throw new SyncPremException(nameof(records)); } using (HttpClient httpClient = new HttpClient()) { using (HttpContent httpContent = new PushStreamContent((s) => this.SerializeRecordsToStream(s, records))) { using (HttpResponseMessage result = await httpClient.PostAsync(fsConfig.WebEndpointUri, httpContent)) { await result.Content.ReadAsStreamAsync(); result.EnsureSuccessStatusCode(); } } } }
protected override async Task ConsumeAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, CancellationToken cancellationToken) { ISchema schema = null; IAsyncEnumerable <IRecord> records; DbDataReader sourceDataReader; long rowsCopied; if ((object)asyncContext == null) { throw new ArgumentNullException(nameof(asyncContext)); } if ((object)configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if ((object)asyncChannel == null) { throw new ArgumentNullException(nameof(asyncChannel)); } this.AssertValidConfiguration(); records = asyncChannel.Records; if ((object)records == null) { throw new SyncPremException(nameof(records)); } /*IAsyncEnumerable<IAsyncGrouping<ISchema, IRecord>> groups; * * groups = records.GroupBy(r => r.Schema); * * foreach (IAsyncGrouping<ISchema, IRecord> grouping in groups) * { * foreach (IRecord record in grouping) * { * } * }*/ sourceDataReader = null; //new AdoNetStreamingPayloadDataReaderAsync(schema.Fields.Values, records.Select(r => r.Payload)); try { await this.ConsumeMessageReaderAsync(asyncContext, configuration, sourceDataReader, cancellationToken); } finally { // just in case ConsumeMessageReaderAsync did not or could not enumerate to completion for disposal... do { while (await sourceDataReader.ReadAsync(cancellationToken)) { ; } }while (await sourceDataReader.NextResultAsync(cancellationToken)) ; } }
public Task <IAsyncChannel> ProcessAsync(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, AsyncProcessDelegate asyncNext, CancellationToken cancellationToken) { Task <IAsyncChannel> newAsyncChannelTask; if ((object)asyncContext == null) { throw new ArgumentNullException(nameof(asyncContext)); } if ((object)configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if ((object)asyncChannel == null) { throw new ArgumentNullException(nameof(asyncChannel)); } newAsyncChannelTask = this.ProcessAsyncInternal(asyncContext, configuration, asyncChannel, asyncNext, cancellationToken); return(newAsyncChannelTask); }
protected abstract Task <IAsyncChannel> ProcessAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, AsyncProcessDelegate asyncNext, CancellationToken cancellationToken);
private Task <IAsyncChannel> TransformAsync(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, CancellationToken cancellationToken) { Console.WriteLine("voo doo!"); return(this.AsyncProcessToNext(asyncContext, configuration, asyncChannel, this.AsyncNext, cancellationToken)); }
protected override async Task ConsumeAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, CancellationToken cancellationToken) { IAsyncEnumerable <IAsyncRecord> records; if ((object)asyncContext == null) { throw new ArgumentNullException(nameof(asyncContext)); } if ((object)configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if ((object)asyncChannel == null) { throw new ArgumentNullException(nameof(asyncChannel)); } this.AssertValidConfiguration(); records = asyncChannel.Records; if ((object)records == null) { throw new SyncPremException(nameof(records)); } IAsyncEnumerator <IAsyncRecord> recordz; recordz = records.GetEnumerator(); if ((object)recordz == null) { throw new InvalidOperationException(nameof(recordz)); } while (await recordz.MoveNext(cancellationToken)) { IAsyncRecord record = recordz.Current; TextWriter.WriteLine(record); } }
protected override async Task ConsumeAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, CancellationToken cancellationToken) { IAsyncEnumerable <IAsyncRecord> asyncRecords; if ((object)asyncContext == null) { throw new ArgumentNullException(nameof(asyncContext)); } if ((object)configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if ((object)asyncChannel == null) { throw new ArgumentNullException(nameof(asyncChannel)); } this.AssertValidConfiguration(); asyncRecords = asyncChannel.Records; if ((object)asyncRecords == null) { throw new SyncPremException(nameof(asyncRecords)); } await asyncRecords.ForceAsyncEnumeration(cancellationToken); // force execution }
protected abstract Task ConsumeAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, CancellationToken cancellationToken);
public Task ConsumeAsync(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, CancellationToken cancellationToken) { Task task; if ((object)asyncContext == null) { throw new ArgumentNullException(nameof(asyncContext)); } if ((object)configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if ((object)asyncChannel == null) { throw new ArgumentNullException(nameof(asyncChannel)); } task = this.ConsumeAsyncInternal(asyncContext, configuration, asyncChannel, cancellationToken); return(task); }