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
using Microsoft.AspNetCore.SignalR; | |
using WebsocketTest; | |
var builder = WebApplication.CreateBuilder(args); | |
builder.Services.AddSignalR(); | |
var app = builder.Build(); | |
app.UseHttpsRedirection(); |
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
using Microsoft.AspNetCore.SignalR; | |
namespace WebsocketTest; | |
public class WSTestHub : Hub | |
{ | |
public async Task DifundirMensaje(string message) | |
{ | |
await Clients.All.SendAsync("MensajeRecibido", message); | |
} | |
} |
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(Name = "GetWeatherForecast")] | |
public async Task<IEnumerable<WeatherForecast>> Get() | |
{ | |
await using var _lock = await _LockFactory.CreateLockAsync( | |
typeof(WeatherForecast).Name, | |
TimeSpan.FromSeconds(10), // need a lock for 10 seconds | |
TimeSpan.FromSeconds(3), // wait 3 seconds to attempt and acquire a lock | |
TimeSpan.FromSeconds(1) // retry every 1 second | |
);| |
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
private IEnumerable<string> ExtractHeaders(IBasicProperties prop, string key) | |
{ | |
try | |
{ | |
if (prop.Headers.TryGetValue(key, out var value)) | |
{ | |
var bytes = value as byte[] ?? throw new Exception("no value"); | |
return new[] { System.Text.Encoding.UTF8.GetString(bytes) }; | |
} | |
} |
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
private static readonly ActivitySource ActivitySource = new ActivitySource("Worker"); | |
private static readonly TextMapPropagator Propagator = new TraceContextPropagator(); | |
const string ACTIVITY_NAME = "Launching handler to process request"; | |
protected override async Task ExecuteAsync(CancellationToken stoppingToken) | |
{ | |
stoppingToken.ThrowIfCancellationRequested(); | |
_model.QueueDeclare(_queueName, false, false, false, null); | |
var consumer = new EventingBasicConsumer(_model); |
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
var serviceName = "Worker"; | |
services.AddOpenTelemetryTracing((builder) => | |
{ | |
builder.AddSource(serviceName) | |
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(serviceName)) | |
.AddHttpClientInstrumentation() | |
.AddZipkinExporter(zipkinOptions => | |
{ | |
zipkinOptions.Endpoint = new Uri("http://localhost:9411/api/v2/spans"); |
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 async Task SendMessage(string Message, string Queue) | |
{ | |
await Task.Run(() => | |
{ | |
using (var activity = _activitySource.StartActivity("Queue user creation request", ActivityKind.Producer)) | |
{ | |
using (var channel = _conn.CreateModel()) | |
{ | |
channel.QueueDeclare(Queue, false, false, false, null); | |
ActivityContext contextToInject = default; |
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
var serviceName = "ApiEntryPoint"; | |
builder.Services.AddOpenTelemetryTracing((builder) => | |
{ | |
builder.AddSource(serviceName) | |
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(serviceName)) | |
.AddAspNetCoreInstrumentation() | |
.AddZipkinExporter(zipkinOptions => | |
{ | |
zipkinOptions.Endpoint = new Uri("http://localhost:9411/api/v2/spans"); | |
}) |
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
const routes: Routes = [ | |
{ path: 'userinfo', component: UserInfoComponent} | |
]; |
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 login() { | |
this.oauthSvc.initLoginFlow() | |
} | |
public logoff() { | |
this.oauthSvc.logOut(); | |
} | |
hitBackend(): void { | |
this.client.get("http://localhost:5000/api/numero").subscribe({ |
NewerOlder