Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create DocumentLoader.LoadAll method #10

Open
bryanrcarlson opened this issue Nov 8, 2018 · 0 comments
Open

Create DocumentLoader.LoadAll method #10

bryanrcarlson opened this issue Nov 8, 2018 · 0 comments

Comments

@bryanrcarlson
Copy link
Member

There is redundant code to load documents into Cosmos in Pipelines. This should be part of the DocumentLoader class.

Example of code:

int docsLoaded = 0;
int docsError = 0;
foreach(SoilSample sample in transformed)
{
  ResourceResponse<Document> result = 
    await loader.LoadNoReplace(sample);
  if(result.StatusCode == HttpStatusCode.Created)
  {
    etlEvent.Outputs.Add(result.Resource.Id);
    docsLoaded++;
  }
  else { docsError++; }

    // Notify data written then sleep to conserve Cosmos RU
    Console.Write(".");
    Thread.Sleep(40);
  }

Function should take "Thread.Sleep" as argument
Function should return a list of successes (or a string?) and list of errors. Possibly a tuple. This info needs to be logged in an EtlEvent:

etlEvent.Logs.Add(
  $"Loaded {docsLoaded.ToString()} SoilSamples");
etlEvent.Logs.Add(
  $"Error loading {docsError.ToString()} SoilSamples");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant