-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#340 loads of refactoring to make configuration work with dynamic rou…
…ting
- Loading branch information
1 parent
f564917
commit 33e422b
Showing
49 changed files
with
848 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ public interface IReRouteOptionsCreator | |
{ | ||
ReRouteOptions Create(FileReRoute fileReRoute); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,47 @@ | ||
using Ocelot.Configuration.Builder; | ||
using Ocelot.Configuration.File; | ||
|
||
namespace Ocelot.Configuration.Creator | ||
{ | ||
using Ocelot.Configuration.Builder; | ||
using Ocelot.Configuration.File; | ||
using System.Linq; | ||
|
||
public class QoSOptionsCreator : IQoSOptionsCreator | ||
{ | ||
public QoSOptions Create(FileReRoute fileReRoute) | ||
public QoSOptions Create(FileQoSOptions options) | ||
{ | ||
return new QoSOptionsBuilder() | ||
.WithExceptionsAllowedBeforeBreaking(fileReRoute.QoSOptions.ExceptionsAllowedBeforeBreaking) | ||
.WithDurationOfBreak(fileReRoute.QoSOptions.DurationOfBreak) | ||
.WithTimeoutValue(fileReRoute.QoSOptions.TimeoutValue) | ||
.WithExceptionsAllowedBeforeBreaking(options.ExceptionsAllowedBeforeBreaking) | ||
.WithDurationOfBreak(options.DurationOfBreak) | ||
.WithTimeoutValue(options.TimeoutValue) | ||
.Build(); | ||
} | ||
|
||
public QoSOptions Create(FileQoSOptions options, string pathTemplate, string[] httpMethods) | ||
{ | ||
var key = CreateKey(pathTemplate, httpMethods); | ||
|
||
return Map(key, options.TimeoutValue, options.DurationOfBreak, options.ExceptionsAllowedBeforeBreaking); | ||
} | ||
|
||
public QoSOptions Create(QoSOptions options, string pathTemplate, string[] httpMethods) | ||
{ | ||
var key = CreateKey(pathTemplate, httpMethods); | ||
|
||
return Map(key, options.TimeoutValue, options.DurationOfBreak, options.ExceptionsAllowedBeforeBreaking); | ||
} | ||
|
||
private QoSOptions Map(string key, int timeoutValue, int durationOfBreak, int exceptionsAllowedBeforeBreaking) | ||
{ | ||
return new QoSOptionsBuilder() | ||
.WithExceptionsAllowedBeforeBreaking(exceptionsAllowedBeforeBreaking) | ||
.WithDurationOfBreak(durationOfBreak) | ||
.WithTimeoutValue(timeoutValue) | ||
.WithKey(key) | ||
.Build(); | ||
} | ||
|
||
private string CreateKey(string pathTemplate, string[] httpMethods) | ||
{ | ||
return $"{pathTemplate.FirstOrDefault()}|{string.Join(",", httpMethods)}"; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.