implementing load balancers

This commit is contained in:
Tom Gardham-Pallister
2017-01-29 09:41:05 +00:00
parent c3a47f66c8
commit 4a43accc46
6 changed files with 427 additions and 27 deletions

View File

@ -46,12 +46,18 @@ namespace Ocelot.DownstreamUrlCreator.Middleware
var dsScheme = DownstreamRoute.ReRoute.DownstreamScheme;
//here we could have a lb factory that takes stuff or we could just get the load balancer from the reRoute?
//returns the lb for this request
//lease the next address from the lb
var dsHostAndPort = DownstreamRoute.ReRoute.DownstreamHostAndPort();
var dsUrl = _urlBuilder.Build(dsPath.Data.Value, dsScheme, dsHostAndPort);
if (dsUrl.IsError)
{
//todo - release the lb connection?
_logger.LogDebug("IUrlBuilder returned an error, setting pipeline error");
SetPipelineError(dsUrl.Errors);
@ -66,6 +72,8 @@ namespace Ocelot.DownstreamUrlCreator.Middleware
await _next.Invoke(context);
//todo - release the lb connection?
_logger.LogDebug("succesfully called next middleware");
}
}

View File

@ -21,6 +21,8 @@
DownstreamPathTemplateContainsSchemeError,
DownstreamPathNullOrEmptyError,
DownstreamSchemeNullOrEmptyError,
DownstreamHostNullOrEmptyError
DownstreamHostNullOrEmptyError,
ServicesAreNullError,
ServicesAreEmptyError
}
}

View File

@ -10,5 +10,10 @@
public string DownstreamHost { get; private set; }
public int DownstreamPort { get; private set; }
public override string ToString()
{
return $"{DownstreamHost}:{DownstreamPort}";
}
}
}