Class: Updater::ORM::ClassMethods

Inherits:
Object
  • Object
show all
Defined in:
lib/updater/orm/orm.rb

Instance Method Summary collapse

Instance Method Details

#after_forkObject



234
235
236
# File 'lib/updater/orm/orm.rb', line 234

def after_fork
  
end

#before_forkObject

This method is called by the child before a fork call. It allows the ORM to clean up any connections Made by the parent and establish new connections if necessary.



230
231
232
# File 'lib/updater/orm/orm.rb', line 230

def before_fork
  
end

#clear_allObject

Compleatly remove all jobs and associeted data from the datastore including chained Methods.



216
217
218
# File 'lib/updater/orm/orm.rb', line 216

def clear_all
  NotImplementedError
end

#clear_locks(worker) ⇒ Object

This method unlocks and makes availible any and all jobs which have been locked by the worker. Workers are uniquely identified by the name method. This is an indication that the worker has died or been killed and cannot complete its job.



210
211
212
# File 'lib/updater/orm/orm.rb', line 210

def clear_locks(worker)
  NotImplementedError
end

#create(hash) ⇒ Object

The hash keys are symbols for the one of the 12 field values listed in the intro to the ORM::Base class. The values are the actual values that should be returned by the accessor methods. Depending on the datastore some values may need to be marshaled converted, etc.. before being written to the datastore.



155
156
157
# File 'lib/updater/orm/orm.rb', line 155

def create(hash)
  NotImplementedError
end

#currentObject

This method returns all jobs that are now ready to run, that is thier time valuse is less then or equal to the value returned by calling now on the registered time class (tnow).



161
162
163
# File 'lib/updater/orm/orm.rb', line 161

def current
  NotImplementedError
end

#current_loadObject

Returns a count of how many jobs are currently ready to run.



166
167
168
# File 'lib/updater/orm/orm.rb', line 166

def current_load
  NotImplementedError
end

#delayedObject

Runurns a count of the number of jobs scheduled to run at a later time, that is there time value is strictly greater then the value returned by calling now on the registered time class(tnow)



173
174
175
# File 'lib/updater/orm/orm.rb', line 173

def delayed
  NotImplementedError
end

#for(mytarget, myfinder, myfinder_args, myname = nil) ⇒ Object

Optional, but strongly recomended.

For any datastore that permits, return and Array of all delayed, chained, and current but not locked jobs that reference mytarget, myfinder, and myfinder_args, that is they clearly have the spesified Target. Optionally, limit the result to return the first job that also has a name value of myname. The name value is spesified as unique per target so the which record is returned in the case that multiple jobs fro the same target share the same name is undefined.



244
245
246
# File 'lib/updater/orm/orm.rb', line 244

def for(mytarget, myfinder, myfinder_args, myname=nil)
  NotImplementedError
end

#future(start, finish) ⇒ Object

Returns a count of how may jobs are curently scheduled between start and finish seconds from now. e.g future(0,60) would tell you how many jobs will run in the next minute. This function is used to adjust the number of workers needed as well as for monitering.



180
181
182
# File 'lib/updater/orm/orm.rb', line 180

def future(start, finish)
  NotImplementedError
end

#get(id) ⇒ Object

When passed the value returned by the #id method of a job, this method must return that job from the datastore.



147
148
149
# File 'lib/updater/orm/orm.rb', line 147

def get(id)
  NotImplementedError
end

#lock_next(worker) ⇒ Object

Locks to a worker and returns a job that is ready to run. Workers will call this when they are ready for another job. In general it should lock jobs in the order they were recieved or scheduled, but strict ordering is not a requirement. (c.f. delayed_job). If there are current jobs, this method MUST return one which has been locked successfully, internally trying successive current jobs if the first one fails to lock. It MUST NOT raise an error or return nil if the datastore is temerarly busy. Instead it must wait until it can either get access to and lock a record, or prove that no jobs are current.

In the event that there are no current jobs left in the datastore this method should retunr nil. The should inturperate this as a sign that the queue is empty and consult queue_time to determine how long to wait for the next job.



203
204
205
# File 'lib/updater/orm/orm.rb', line 203

def lock_next(worker)
  NotImplementedError
end

#queue_timeObject

Returns the number os seconds until the next job will be ready to run. If there are no Jobs in the queue it returns nil, if there is at least one job ready to run it MUST return

  1. This may be an apporximation or the value may be cached for brief periods to improve

datastore performance.



188
189
190
# File 'lib/updater/orm/orm.rb', line 188

def queue_time
  NotImplementedError
end

#setup(options) ⇒ Object

This method is the generic way to setup the datastore. Options is a hash one of whose fields will be :logger, the logger instance to pass on to the ORM. The rest of the options are ORM spesific. The function should prepair a connection to the datastore using the given options. If the connection cannot be prepaired then an appropriate error should be raised.



224
225
226
# File 'lib/updater/orm/orm.rb', line 224

def setup(options)
  NotImplementedError 
end