Skip to content

Commit

Permalink
Add 'Name' property to ILoadBalancer, for future use in LoadBalancerF…
Browse files Browse the repository at this point in the history
…actory.
  • Loading branch information
David Lievrouw committed Mar 15, 2020
1 parent 347ea72 commit 789782c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Ocelot/LoadBalancer/LoadBalancers/CookieStickySessions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,7 @@ public async Task<Response<ServiceHostAndPort>> Lease(DownstreamContext context)
public void Release(ServiceHostAndPort hostAndPort)
{
}

public string Name => GetType().Name;
}
}
2 changes: 2 additions & 0 deletions src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ public interface ILoadBalancer
Task<Response<ServiceHostAndPort>> Lease(DownstreamContext context);

void Release(ServiceHostAndPort hostAndPort);

string Name { get; }
}
}
2 changes: 2 additions & 0 deletions src/Ocelot/LoadBalancer/LoadBalancers/LeastConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public void Release(ServiceHostAndPort hostAndPort)
}
}

public string Name => GetType().Name;

private Lease AddConnection(Lease lease)
{
return new Lease(lease.HostAndPort, lease.Connections + 1);
Expand Down
2 changes: 2 additions & 0 deletions src/Ocelot/LoadBalancer/LoadBalancers/NoLoadBalancer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ public async Task<Response<ServiceHostAndPort>> Lease(DownstreamContext downstre
public void Release(ServiceHostAndPort hostAndPort)
{
}

public string Name => GetType().Name;
}
}
2 changes: 2 additions & 0 deletions src/Ocelot/LoadBalancer/LoadBalancers/RoundRobin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ public async Task<Response<ServiceHostAndPort>> Lease(DownstreamContext downstre
public void Release(ServiceHostAndPort hostAndPort)
{
}

public string Name => GetType().Name;
}
}
4 changes: 4 additions & 0 deletions test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ public void Release(ServiceHostAndPort hostAndPort)
{
throw new NotImplementedException();
}

public string Name => GetType().Name;
}

private class FakeRoundRobinLoadBalancer : ILoadBalancer
Expand All @@ -177,6 +179,8 @@ public void Release(ServiceHostAndPort hostAndPort)
{
throw new NotImplementedException();
}

public string Name => GetType().Name;
}
}
}

0 comments on commit 789782c

Please sign in to comment.