News for hackers. Stuff that matters.
Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by tvon on Tuesday August 19, 2014 @11:42PM (#8201006)
So GlobalID means instead of doing `SomeJob.enqueue(instance.id)` (and then `Model.find(id)` in the job) you just do `SomeJob.enqueue(instance)`, and presumably reference something like `object` in the job?
Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by swanson on Wednesday August 20, 2014 @12:05AM (#8201053)
Yes - there is a good example on the ActiveJob README (https://github.com/rails/activejob#globalid-support).
Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by sync on Wednesday August 20, 2014 @01:50AM (#8201233)
We frequently ran into the issue of the object having been deleted while sitting in the job queue, so Model.find(id) would blow up. I'd be curious to hear if GlobalID did anything about that.
Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by DouweM on Wednesday August 20, 2014 @04:51AM (#8201577)
We had a bit of a discussion about that, finally settling on adding `rescue_from` which you'll know from ActionController and raising a `ActiveJob::DeserializationError` wrapping `ActiveRecord::RecordNotFound`, allowing you to handle this lookup failure however you see fit.

See the original discussion here: https://github.com/rails/activejob/issues/25

The discussion was then continued here: https://github.com/rails/rails/pull/16485#discussion-diff-16..., which is where the `ActiveJob::DeserializationError` comes from.

Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by damncabbage on Wednesday August 20, 2014 @02:23AM (#8201293)
This won't do anything for you there; it just collapses a Class and a record ID down into a string for you (and then pulls it back out of your database later with a GlobalID::Locator.locate(string) call).

It's not full-record-serialization, and it can't bring back deleted records for you.

(See https://github.com/rails/rails/tree/master/activejob#globali... for an example.)

Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by joevandyk on Wednesday August 20, 2014 @12:03AM (#8201048)
You do GlobalID.locate(gid) in the job.
Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by DouweM on Wednesday August 20, 2014 @04:47AM (#8201562)
That's incorrect. The global ID sent along the wire is transparently looked up at deserialization.

See the example here: https://github.com/rails/rails/tree/master/activejob#globali...

Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by mbs348 on Wednesday August 20, 2014 @12:03AM (#8201044)
Yes, exactly. It is an interesting/cool idea to create an object URI to make this possible!
Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by hayksaakian on Wednesday August 20, 2014 @02:44AM (#8201327)
Beware, this behavior lets you shoot yourself in the foot because when you conduct your job, you might be working with a stale object that's changed since the job went on the queue.
Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by DouweM on Wednesday August 20, 2014 @04:46AM (#8201561)
That's incorrect. This is not YAML-style full object serialization, but rather a global ID being sent along the wire that is transparently looked up at deserialization.

See the example here: https://github.com/rails/rails/tree/master/activejob#globali...

Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by hayksaakian on Wednesday August 20, 2014 @05:31AM (#8201656)
Is it? I assumed it worked like delayed_job which gave me issues due to the problem I mentioned.
Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by DouweM on Wednesday August 20, 2014 @06:03AM (#8201727)
It is! That's the exact problem ActiveJob+GlobalID tries to solve.
Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by hayksaakian on Wednesday August 20, 2014 @01:23PM (#8203309)
I suppose I was mistaken then, thanks for helping me understand.
Re:Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Re... by volkk on Wednesday August 20, 2014 @10:20AM (#8202366)
why bother spreading false information without even taking a minute to read into what it actually does?