public FusionAuthenticationBuilder AddServerSideAuthService(Type?implementationType = null) { if (Services.Any(d => d.ServiceType == typeof(IServerSideAuthService))) { return(this); } implementationType ??= typeof(InMemoryAuthService); var serverSideServiceType = typeof(IServerSideAuthService); if (!serverSideServiceType.IsAssignableFrom(implementationType)) { throw Errors.MustImplement(implementationType, serverSideServiceType, nameof(implementationType)); } Fusion.AddComputeService(serverSideServiceType, implementationType); Services.TryAddTransient <IAuthService>(c => c.GetRequiredService <IServerSideAuthService>()); return(this); }
protected virtual async Task NotifyAsync() { var qPayload = AgentInfo.Id.Value.Replace("'", "''"); TDbContext?dbContext = null; try { using (await AsyncLock.LockAsync()) { if (IsDisposed) { throw Errors.AlreadyDisposed(); } dbContext = DbContext ??= CreateDbContext(); await dbContext.Database .ExecuteSqlRawAsync($"NOTIFY {Options.ChannelName}, '{qPayload}'") .ConfigureAwait(false); } } catch { DbContext = null; Notify(Options.RetryDelay); // Retry dbContext?.DisposeAsync().Ignore(); // Doesn't matter if it fails } }