public EFCoreStorage(
     Func <DbContext> dbContextBuilder,
     EFCoreStorageOptions options)
 {
     _dbContextBuilder    = dbContextBuilder ?? throw new ArgumentNullException(nameof(dbContextBuilder));
     _options             = options ?? throw new ArgumentNullException(nameof(options));
     DefaultQueueProvider = new EFCoreJobQueueProvider(this);
 }
Beispiel #2
0
        public override IFetchedJob FetchNextJob(
            [NotNull] string[] queues,
            CancellationToken cancellationToken)
        {
            if (queues is null)
            {
                throw new ArgumentNullException(nameof(queues));
            }
            if (queues.Length == 0)
            {
                throw new ArgumentException(CoreStrings.ArgumentExceptionCollectionCannotBeEmpty,
                                            nameof(queues));
            }

            var provider = new EFCoreJobQueueProvider(_storage);
            var queue    = provider.GetJobQueue();

            return(queue.Dequeue(queues, cancellationToken));
        }
        public EFCoreStorage(
            Action <DbContextOptionsBuilder> optionsAction,
            EFCoreStorageOptions options)
        {
            if (optionsAction is null)
            {
                throw new ArgumentNullException(nameof(optionsAction));
            }
            if (options is null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _options = options;
            var contextOptionsBuilder = new DbContextOptionsBuilder <HangfireContext>();

            optionsAction.Invoke(contextOptionsBuilder);
            _contextOptions      = contextOptionsBuilder.Options;
            DefaultQueueProvider = new EFCoreJobQueueProvider(this);
        }