public void Set_QueuePollInterval_ShouldThrowAnException_WhenGivenIntervalIsNegative() { var storageOptions = new LiteDbStorageOptions(); Assert.Throws <ArgumentException>( () => storageOptions.QueuePollInterval = TimeSpan.FromSeconds(-1)); }
public void Ctor_SetsTheDefaultOptions() { LiteDbStorageOptions storageOptions = new LiteDbStorageOptions(); Assert.Equal("hangfire", storageOptions.Prefix); Assert.True(storageOptions.InvisibilityTimeout > TimeSpan.Zero); }
public void Set_QueuePollInterval_ShouldThrowAnException_WhenGivenIntervalIsEqualToZero() { var storageOptions = new LiteDbStorageOptions(); Assert.Throws <ArgumentException>( () => storageOptions.QueuePollInterval = TimeSpan.Zero); }
public void Set_QueuePollInterval_SetsTheValue() { var storageOptions = new LiteDbStorageOptions { QueuePollInterval = TimeSpan.FromSeconds(1) }; Assert.Equal(TimeSpan.FromSeconds(1), storageOptions.QueuePollInterval); }
/// <summary> /// Configure Hangfire to use LiteDB storage /// </summary> /// <param name="configuration">Configuration</param> /// <param name="connectionString">Connection string for LiteDB database, for example 'LiteDB://*****:*****@host:port'</param> /// <param name="storageOptions">Storage options</param> /// <returns></returns> public static LiteDbStorage LiteDbStorage(this IGlobalConfiguration configuration, string connectionString, LiteDbStorageOptions storageOptions) { var storage = new LiteDbStorage(connectionString, storageOptions); configuration.UseStorage(storage); return(storage); }
public void Ctor_SetsTheDefaultOptions_ShouldGenerateUniqueClientId() { var storageOptions1 = new LiteDbStorageOptions(); var storageOptions2 = new LiteDbStorageOptions(); var storageOptions3 = new LiteDbStorageOptions(); IEnumerable <string> result = new[] { storageOptions1.ClientId, storageOptions2.ClientId, storageOptions3.ClientId }.Distinct(); Assert.Equal(3, result.Count()); }
public static LiteDbStorage GetLiteDbStorage(string connectionString) { Log.Information("HangfireLiteDb: {0}", connectionString); var options = new LiteDbStorageOptions() { QueuePollInterval = TimeSpan.FromSeconds(10) }; var storage = new LiteDbStorage(connectionString, options); return(storage); }
public static LiteDbStorage GetLiteDbStorage() { var connectionString = BotSettings.HangfireLiteDb; Log.Information($"HangfireLiteDb: {connectionString}"); var options = new LiteDbStorageOptions() { QueuePollInterval = TimeSpan.FromSeconds(10) }; var storage = new LiteDbStorage(connectionString, options); return(storage); }
public static LiteDbStorage CreateStorage(LiteDbStorageOptions storageOptions) { return(new LiteDbStorage(GetConnectionString(), storageOptions)); }
public static LiteDbStorage CreateStorage() { var storageOptions = new LiteDbStorageOptions(); return(CreateStorage(storageOptions)); }
public void Ctor_SetsTheDefaultOptions_ShouldGenerateClientId() { var storageOptions = new LiteDbStorageOptions(); Assert.False(String.IsNullOrWhiteSpace(storageOptions.ClientId)); }
public void ConfigureServices(IServiceCollection services) { services .AddTransient <ZiziBot>() .Configure <BotOptions <ZiziBot> >(Configuration.GetSection("ZiziBot")) .Configure <CustomBotOptions <ZiziBot> >(Configuration.GetSection("ZiziBot")) .AddTransient <MacOsBot>() .Configure <BotOptions <MacOsBot> >(Configuration.GetSection("MacOsBot")) .Configure <CustomBotOptions <MacOsBot> >(Configuration.GetSection("MacOsBot")) .AddScoped <NewUpdateHandler>() .AddScoped <GenericMessageHandler>() .AddScoped <WebhookLogger>() .AddScoped <StickerHandler>() .AddScoped <WeatherReporter>() .AddScoped <ExceptionHandler>() .AddScoped <UpdateMembersList>() .AddScoped <CallbackQueryHandler>() .AddScoped <IWeatherService, WeatherService>(); services.AddScoped <GlobalBanCommand>() .AddScoped <DelBanCommand>(); services.AddScoped <WordFilterCommand>() .AddScoped <WordSyncCommand>(); services.AddScoped <PingHandler>() .AddScoped <HelpCommand>() .AddScoped <TestCommand>(); services.AddScoped <MediaReceivedHandler>(); services.AddScoped <MigrateCommand>() .AddScoped <MediaFilterCommand>(); services.AddScoped <CallTagsReceivedHandler>() .AddScoped <TagsCommand>() .AddScoped <TagCommand>() .AddScoped <UntagCommand>(); services.AddScoped <NotesCommand>() .AddScoped <AddNotesCommand>(); services.AddScoped <SetRssCommand>() .AddScoped <DelRssCommand>() .AddScoped <RssInfoCommand>() .AddScoped <RssPullCommand>() .AddScoped <RssCtlCommand>(); services.AddScoped <AdminCommand>() .AddScoped <PinCommand>() .AddScoped <ReportCommand>() .AddScoped <AfkCommand>(); services.AddScoped <KickCommand>() .AddScoped <BanCommand>(); services.AddScoped <PromoteCommand>() .AddScoped <DemoteCommand>(); services.AddScoped <RulesCommand>(); services.AddScoped <NewChatMembersEvent>() .AddScoped <LeftChatMemberEvent>() .AddScoped <PinnedMessageEvent>(); services.AddScoped <WelcomeCommand>(); services.AddScoped <SetWelcomeCommand>(); services.AddScoped <PingCommand>() .AddScoped <DebugCommand>() .AddScoped <StartCommand>() .AddScoped <IdCommand>() .AddScoped <InfoCommand>(); services.AddScoped <OutCommand>(); services.AddScoped <QrCommand>(); // Hangfire var hangfireOptions = new LiteDbStorageOptions { QueuePollInterval = TimeSpan.FromSeconds(5) }; services.AddHangfireServer(); services.AddHangfire(t => { t.UseLiteDbStorage(Configuration["Hangfire:LiteDb"], hangfireOptions); t.UseHeartbeatPage(checkInterval: TimeSpan.FromSeconds(1)); t.UseSerilogLogProvider(); }); }
public static LiteDbStorage CreateStorage(LiteDbStorageOptions storageOptions) { var connectionString = GetConnectionString(); return(new LiteDbStorage(connectionString, storageOptions)); }