Module: PerfectSched

Defined in:
lib/perfectsched.rb,
lib/perfectsched/task.rb,
lib/perfectsched/error.rb,
lib/perfectsched/model.rb,
lib/perfectsched/client.rb,
lib/perfectsched/engine.rb,
lib/perfectsched/runner.rb,
lib/perfectsched/worker.rb,
lib/perfectsched/backend.rb,
lib/perfectsched/version.rb,
lib/perfectsched/schedule.rb,
lib/perfectsched/application.rb,
lib/perfectsched/signal_queue.rb,
lib/perfectsched/blocking_flag.rb,
lib/perfectsched/signal_thread.rb,
lib/perfectsched/daemons_logger.rb,
lib/perfectsched/application/base.rb,
lib/perfectsched/schedule_metadata.rb,
lib/perfectsched/application/router.rb,
lib/perfectsched/backend/rdb_compat.rb,
lib/perfectsched/application/decider.rb,
lib/perfectsched/schedule_collection.rb,
lib/perfectsched/application/dispatch.rb

Overview

PerfectSched

Copyright © 2012 FURUHASHI Sadayuki

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Defined Under Namespace

Modules: Application, Backend, BackendHelper, IdempotentError, Model, ScheduleMetadataAccessors Classes: AlreadyExistsError, AlreadyFinishedError, Client, ConfigError, Engine, IdempotentAlreadyExistsError, IdempotentAlreadyFinishedError, IdempotentNotFoundError, NotFoundError, NotSupportedError, PreemptedError, ProcessStopError, Runner, Schedule, ScheduleCollection, ScheduleError, ScheduleWithMetadata, Task, Worker

Constant Summary collapse

VERSION =
"0.8.12"
SignalQueue =
PerfectQueue::SignalQueue
BlockingFlag =
PerfectQueue::BlockingFlag
SignalThread =
PerfectQueue::SignalThread
DaemonsLogger =
PerfectQueue::DaemonsLogger

Class Method Summary collapse

Class Method Details

.cron_time(cron, timestamp, timezone) ⇒ Object



73
74
75
76
77
# File 'lib/perfectsched.rb', line 73

def self.cron_time(cron, timestamp, timezone)
  ts = timestamp - 1 # compatibility
  t = Time.find_zone!(timezone || 'UTC'.freeze).at(ts)
  Chrono::NextTime.new(now: t, source: cron).to_time.to_i
end

.next_time(cron, before_timestamp, timezone) ⇒ Object



79
80
81
# File 'lib/perfectsched.rb', line 79

def self.next_time(cron, before_timestamp, timezone)
  cron_time(cron, before_timestamp+1, timezone)
end

.open(config, &block) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/perfectsched.rb', line 58

def self.open(config, &block)
  c = Client.new(config)
  begin
    q = ScheduleCollection.new(c)
    if block
      block.call(q)
    else
      c = nil
      return q
    end
  ensure
    c.close if c
  end
end