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
| [Rule(Category = "Customer", priority = 0)] | |
| public class MustBe18 | |
| { | |
| [Run] | |
| public bool IsValid(CustomerRuleContext ctx) => | |
| ctx.Dob.Date.AddYears(18) <= DateTime.Today.Date; | |
| } | |
| [Rule(Category = "Customer", priority = 1)] | |
| public class MustLiveInCurrentAddressAtLeast1Year |
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 class LendingRule | |
| { | |
| // shared private state all delcared at the top. | |
| // no clear sense as which state is used by which rule, | |
| // apart from giving them a good name or making comments, | |
| // there are no real provision on encapsulation. | |
| public static int Duration = 30; | |
| private int ageOf = 18; | |
| private decimal minimumIncomeOf = 30000; | |
| private int minmumCreditScoreOf = 100; |
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 class StepdownRule | |
| { | |
| public static int Duration = 30; | |
| public static bool IsInStepdown(DateTime? dateLendingDecisionMade) | |
| { | |
| return dateLendingDecisionMade.HasValue && | |
| GetRemainingDays(dateLendingDecisionMade.Value) >= 0; | |
| } | |
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 System; | |
| using System.Net; | |
| using System.Net.Http; | |
| using System.Text; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| using Confluent.Kafka; | |
| using Polly; | |
| using Polly.Contrib.WaitAndRetry; |
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 Microsoft.Extensions.DependencyInjection; | |
| using Microsoft.Extensions.Hosting; | |
| namespace RetrykafkaConsumer | |
| { | |
| public class Program | |
| { | |
| public static void Main(string[] args) | |
| { | |
| CreateHostBuilder(args).Build().Run(); |
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 System; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| using Microsoft.Extensions.DependencyInjection; | |
| using Microsoft.Extensions.Hosting; | |
| using Microsoft.Extensions.Logging; | |
| namespace RetrykafkaConsumer | |
| { | |
| public class Worker : BackgroundService |
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 System; | |
| using Confluent.Kafka; | |
| using Newtonsoft.Json; | |
| namespace retry | |
| { | |
| public interface IKafkaProducer | |
| { | |
| void Produce<T>(string msgKey, T msgVal, string topic = "retry-transient-error"); | |
| } |
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 System; | |
| using System.Collections.Generic; | |
| using System.IO; | |
| using System.Linq; | |
| using System.Net.Http; | |
| using System.Text.Json; | |
| using System.Text.Json.Serialization; | |
| using System.Threading.Tasks; | |
| using Polly.Contrib.Simmy; | |
| using Polly.Contrib.Simmy.Outcomes; |
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 System; | |
| using System.Collections.Generic; | |
| using System.Threading.Tasks; | |
| using Microsoft.AspNetCore.Mvc; | |
| namespace retry.Controllers | |
| { | |
| [ApiController] | |
| [Route("[controller]/[action]")] | |
| public class RetryController : ControllerBase |
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
| Start Kafka server | |
| kafka-server-start /usr/local/etc/kafka/server.properties | |
| Start Zookeeper | |
| zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties | |
| Create Kafka Topic | |
| kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test | |
| Initialize Producer console |
NewerOlder