Comments (11)
Those semantics are the same for Redis and in-memory too.
Adding the semantics as you request would add a lot of complexity and push GF closer to being a full MQ system. That's not my vision for girl_friday. Do you have any thoughts on how to change this simply?
from girl_friday.
When the pop occurs it needs to pass along a job id also.
def pop
val = collection.find_and_modify(:sort => [['$natural', 1]],
:query => {:status => 'push'},
:update => {:status => 'pop'},
)
[ Marshal.load(val["work"]), val['_id'] ] if val
end
Right now it seems like the job removal can be done in a simple way outside of the library code.
GirlFriday::WorkQueue.new(store: GirlFriday::Store::Mongo) do |opts, id|
JobProcessor.process(opts)
collection.remove({:_id => id, :status => 'pop'})
end
So it seems like there should be a way to push that back into the library in a simple way. If not in a more direct way, perhaps using a GirFirday::MongoQueue that wraps its block with the removal logic (and sets the store option).
from girl_friday.
This was brought up the other day when I was demoing GF at a lunch-and-learn and sounded like a bit of a block for that team.
from girl_friday.
So we aren't the first ones using Mongoid with find_and_modify instead of a queue:
http://blog.boxedice.com/2011/09/28/replacing-rabbitmq-with-mongodb/
They say to avoid the remove (causes write locks) and just use a capped collection (fixed size and will start dropping old records once it fills) . The weakness of using a capped collection is sharding, but it seems that we are already sharding per job queue, and you could always start creating multiple queues per job type when you need too.
That means for MongoDB no changes to GirlFriday are requied. So as far as I am concerned this issue is solved for MongoDB. I will send a pull request next week.
I will leave this issue open as a reminder to you to make the documentation clear that the in memory and Redis stores will drop the queue on a server crash.
from girl_friday.
@gregwebs thanks for the info, but just to be clear, we only support the in-memory & Redis backends. The mongo backend was just an example I threw together one morning, which is why it's in the examples folder. But I'll definitely check out a pull request if it improves the example.
from girl_friday.
I updated the wiki to state that the queue will be lost when Redis goes down.
I now discovered that MogoDB has tailable cursors! This is perfect for a queue, you get messages without polling, but the implementation may not match up well with the current GirlFriday backend API.
from girl_friday.
Why would the queue be lost if Redis goes down? Redis is persistent, that's why we support it - in-memory for best effort processing, redis for more reliable processing. Its list structure is a natural fit for a queue.
from girl_friday.
I have never used Redis. I was under the impression that it is always used
to enhance performance but never as an authoritative data store.
Here is their persistence documentation: http://redis.io/topics/persistence
So it does appear that you can achieve persistence by using an append only
file and fsyncing every operation. However, they seem to discourage that by
calling it "very slow", and i have the (possibly mistaken) impression that
very few users are using this setting.
But even if you use these settings you are still in big trouble when you
have a hard drive failure- personally I wouldn't consider a store persistent
unless it supported replication.
Feel free to update the wiki as you see fit.
On Fri, Sep 30, 2011 at 7:44 AM, Mike Perham <
[email protected]>wrote:
Why would the queue be lost if Redis goes down? Redis is persistent,
that's why we support it - in-memory for best effort processing, redis for
more reliable processing. Its list structure is a natural fit for a queue.Reply to this email directly or view it on GitHub:
#35 (comment)
from girl_friday.
Redis supports replication also. http://redis.io/topics/replication
from girl_friday.
We're not guaranteeing the durability of your out of app database, just that if your app were to go down, your jobs would not necessarily disappear.
from girl_friday.
Cool, obviously I don't know much about Redis :). I updated the wiki to note
that Redis needs to be configured for the data to last a Redis crash. I
think it is much more important to be clear on the limitations a project has
then its actual features. That way people like me won't get confused :)
On Fri, Sep 30, 2011 at 9:06 AM, Jesse Cooke <
[email protected]>wrote:
We're not guaranteeing the durability of your out of app database, just
that if your app were to go down, your jobs would not necessarily disappear.Reply to this email directly or view it on GitHub:
#35 (comment)
from girl_friday.
Related Issues (20)
- Missing License? HOT 2
- With Unicorn, production mode, and unicorn's preload_app, work isn't being completed HOT 15
- Setting up girl_friday in sinatra app HOT 2
- Doesn't work with Passenger HOT 10
- Use Celluloid for actors HOT 5
- Specs fail on Gentoo HOT 4
- Rails 3 with girl_friday server HOT 1
- GirlFriday::Batch exhibits odd behavior HOT 4
- release latest as 0.9.8, please? HOT 10
- Race condition in test_should_allow_graceful_shutdown
- Rubinius to drop actor.rb in favor of rubinius-actor gem HOT 4
- Using GF for periodic tasks on Heroku HOT 1
- undefined method `with' for nil:NilClass HOT 5
- Any method to check if a task is running? HOT 4
- superclass mismatch for class Actor HOT 1
- Intermittent JRuby 1.7.0 failures HOT 2
- When included in a Rails app, test suites always return 0 exit status HOT 2
- Actor class in global scope? HOT 4
- Actor class conflict with private Actor class in project such as Rails HOT 1
- Change Name to "person_friday" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from girl_friday.