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
public class RabbitMqTriggerBinding : ITriggerBinding | |
{ | |
private readonly ILogger _logger; | |
public Type TriggerValueType => typeof(BasicDeliverEventArgs); | |
public IReadOnlyDictionary<string, Type> BindingDataContract => new Dictionary<string, Type>(); | |
private readonly ParameterInfo _parameter; |
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
public class RabbitMqTriggerListener : IListener | |
{ | |
private readonly ITriggeredFunctionExecutor _executor; | |
private readonly RabbitMqTriggerAttribute _attribute; | |
IModel _model { get; } | |
IBasicPublishBatch _createBasicPublishBatch => CreateBasicPublishBatch(); | |
private string _connectionString; | |
private string _hostName; | |
private string _queueName; |
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
[Binding] | |
[AttributeUsage(AttributeTargets.Parameter)] | |
public class RabbitMqTriggerAttribute : Attribute | |
{ | |
public string HostName { get; set; } | |
public string Username { get; set; } | |
public string Password { get; set; } | |
public string Port { get; set; } | |
public string Connection { get; set; } |
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
[HttpGet("{customerid}")] | |
[Cached(Constants.Day_In_Seconds)] | |
public async Task<IActionResult> GetCustomerBasket(Guid customerid) | |
{ | |
var basket = await _consulHttpClient.GetAsync<BasketDto>("basket-service", $"/basket/{customerid}"); | |
return Ok(basket); | |
} |
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
public class ConsulHttpClient : IConsulHttpClient | |
{ | |
private readonly HttpClient _client; | |
private IConsulClient _consulclient; | |
public ConsulHttpClient(HttpClient client, IConsulClient consulclient) | |
{ | |
_client = client; | |
_consulclient = consulclient; | |
} |
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
public static IServiceCollection AddConsul(this IServiceCollection serviceCollection) | |
{ | |
IConfiguration configuration; | |
using (var serviceProvider = serviceCollection.BuildServiceProvider()) | |
{ | |
configuration = serviceProvider.GetService<IConfiguration>(); | |
} | |
ConsulOptions consulConfigOptions = configuration.GetOptions<ConsulOptions>("Consul"); | |
serviceCollection.Configure<ConsulOptions>(configuration.GetSection("Consul")); |
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
COPY *.csproj . | |
RUN dotnet restore | |
# Copy everything else and build | |
COPY . . | |
RUN dotnet publish -c Release -o out |
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
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] | |
public class CachedAttribute : Attribute, IAsyncActionFilter | |
{ | |
private readonly int _timeToLiveSeconds; | |
public CachedAttribute(int timeToLiveSeconds) | |
{ | |
_timeToLiveSeconds = timeToLiveSeconds; | |
} |
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
public class ResponseCacheService : IResponseCacheService | |
{ | |
private readonly IDistributedCache _distributedCache; | |
public ResponseCacheService(IDistributedCache distributedCache) | |
{ | |
_distributedCache = distributedCache; | |
} | |
public async Task CacheResponseAsync(string cacheKey, object response, TimeSpan timeTimeLive) |
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
public static IServiceCollection AddRedis(this IServiceCollection services, IConfiguration configuration) | |
{ | |
var redisCacheSettings = new RedisOptions(); | |
configuration.GetSection(SectionName).Bind(redisCacheSettings); | |
services.AddSingleton(redisCacheSettings); | |
if (!redisCacheSettings.Enabled) | |
{ | |
return services; | |
} |