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

Hide all the timeouts within one transaction for RavenDB #105

Open
lailabougria opened this issue Jun 24, 2020 · 0 comments
Open

Hide all the timeouts within one transaction for RavenDB #105

lailabougria opened this issue Jun 24, 2020 · 0 comments

Comments

@lailabougria
Copy link
Contributor

lailabougria commented Jun 24, 2020

Already tried to set this up for Raven3, but couldn't get it fully functional:

public async Task<bool> HideTimeouts(DateTime cutoffDate)
{
      var cutoffDateParameter = cutoffDate.ToString("YYYY-MM-DDThh:mm:ssZ");
      cutoffDateParameter = cutoffDateParameter.Replace(":", "\\:"); // escape characters for lucene
      var dateRangeSpecification = $"Time:[{cutoffDateParameter} TO *]";
      var patch = new Patch()
      {
           Script = $"this.OwningTimeoutManager = this.OwningTimeoutManager.substr({RavenConstants.MigrationOngoingPrefix.Length});",
          Values = new { }
      };

      var patchCommand = JsonConvert.SerializeObject(patch);
      var url = $"{serverUrl}/databases{databaseName}/bulk_docs/TimeoutsIndex?query={Uri.EscapeDataString(dateRangeSpecification)}&allowStale=false";

      var encoded = Encoding.UTF8.GetBytes(patchCommand);
      var compressed = Compress(encoded);
      using var httpContent = new StringContent(Convert.ToBase64String(compressed), Encoding.UTF8, "application/json");
      using var request = new HttpRequestMessage(new HttpMethod("EVAL"), url){  Content = httpContent};
      var result = await httpClient.SendAsync(request);

      return result.IsSuccessStatusCode;
 }
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