Tool for autoscaling cosmos.
First of all initialize CustomDocumentClient with Url and Authkey.
var customDocumentClient = CustomDocumentClient.Of("Url", "Authkey");
If you initialize it like this, you will have default settings if you use the common executeasync. To Initialize with settings:
var customConfiguration = new CustomConfiguration {
MaxRetries = 10,
MinThroughput = 1000,
MaxThroughput = 10000,
ScaleUpBatch = 200,
ScaleDownBatch = 100
};
var customDocumentClient = CustomDocumentClient.Of("Url", "Authkey", customConfiguration);
Once you have the client initialized, you should use Execute or ExecuteAsync for all the requests. There is two methods of Execute in order to use the common configuration or sending params if you have your environment configured.
Task<T> ExecuteAsync<T>(Func<IDocumentClient, Task<T>> func, string database, string collection, int retries = 0);
Task<T> ExecuteAsync<T>(Func<IDocumentClient, Task<T>> func, string database, string collection, int minThroughput, int maxThroughput, int scaleUpBatch, int retries = 0);
await _customDocumentClient.ExecuteAsync(x => x.UpsertDocumentAsync(collectionUri, data), database, collection).ConfigureAwait(false);
For now, there is only one method for scale down all the collections with the current configuration (Working on it).
await customClient.ScaleDownAll().ConfigureAwait(false);