Skip to content

Commit

Permalink
Voting to scale in or scale out
Browse files Browse the repository at this point in the history
  • Loading branch information
tpeczek committed Feb 21, 2024
1 parent 27fd99e commit 554c92b
Showing 1 changed file with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Host.Scale;
using Microsoft.Extensions.Logging;

namespace RethinkDb.Azure.WebJobs.Extensions.Trigger
{
Expand Down Expand Up @@ -33,18 +35,36 @@ public Task<RethinkDbTriggerMetrics> GetMetricsAsync()

public ScaleStatus GetScaleStatus(ScaleStatusContext<RethinkDbTriggerMetrics> context)
{
throw new NotImplementedException();
return GetScaleStatus(context.WorkerCount, context.Metrics?.ToArray());
}

public ScaleStatus GetScaleStatus(ScaleStatusContext context)
{
throw new NotImplementedException();
return GetScaleStatus(context.WorkerCount, context.Metrics?.Cast<RethinkDbTriggerMetrics>().ToArray());
}

Task<ScaleMetrics> IScaleMonitor.GetMetricsAsync()
{
return Task.FromResult((ScaleMetrics)_rethinkDbMetricsProvider.GetMetrics());
}

private ScaleStatus GetScaleStatus(int workerCount, RethinkDbTriggerMetrics[] metrics)
{
ScaleStatus status = new ScaleStatus
{
Vote = ScaleVote.None
};

// RethinkDB change feed is not meant to be processed in paraller.
if (workerCount > 1)
{
status.Vote = ScaleVote.ScaleIn;

return status;
}

return status;
}
#endregion
}
}

0 comments on commit 554c92b

Please sign in to comment.