This file contains hidden or 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
[ApiVersionNeutral] | |
[Route("api/optout")] | |
public class OptOutControler : Controller | |
{ | |
[HttpGet] | |
public string Get() => HttpContext.GetRequestedApiVersion().ToString(); | |
} |
This file contains hidden or 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
namespace Product.CommandService.Controllers.Product.V1 | |
{ | |
[ApiVersion("1.0")] | |
[Produces("application/json")] | |
[Route("api/Product")] | |
public class ProductController : Controller | |
{ | |
} | |
} |
This file contains hidden or 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
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc(); | |
services.AddApiVersioning(o => o.ApiVersionReader = new HeaderApiVersionReader("api-version")); | |
} |
This file contains hidden or 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
using Confluent.Kafka; | |
using Confluent.Kafka.Serialization; | |
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
namespace kafka_consumer | |
{ | |
class Program | |
{ |
This file contains hidden or 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
using Confluent.Kafka; | |
using Confluent.Kafka.Serialization; | |
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
namespace kafka_prototype | |
{ | |
class Program | |
{ |
This file contains hidden or 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
Policy | |
.Timeout(30, onTimeout: (context, timespan, task) => | |
{ | |
YourFunctionWhenTimeout(); | |
}); |
This file contains hidden or 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
Policy | |
.Handle<Exception>() | |
.Fallback<UserAvatar>(() => UserAvatar.GetRandomAvatar()) |
This file contains hidden or 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
Action<Exception, TimeSpan> onBreak = (exception, timespan) => { ... }; | |
Action onReset = () => { ... }; | |
CircuitBreakerPolicy breaker = Policy | |
.Handle<Exception>() | |
.CircuitBreaker(2, TimeSpan.FromMinutes(1), onBreak, onReset); |
This file contains hidden or 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
Policy | |
.Handle<Exception>() | |
.CircuitBreaker(2, TimeSpan.FromMinutes(1)); |
This file contains hidden or 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
Policy | |
.Handle<Exception>() | |
.WaitAndRetry(new[] | |
{ | |
TimeSpan.FromSeconds(1), | |
TimeSpan.FromSeconds(2), | |
TimeSpan.FromSeconds(3) | |
}, (exception, timeSpan, context) => { | |
YourFunction(); | |
}); |