在各应用程序中复制数据
Promiscuous is a pub-sub framework for easily replicating data across your Ruby applications. Promiscuous guarantees that a subscriber never sees out of order updates and that all updates are eventually replicated.
Benefits over database replication
We need a few things for the promiscuous tutorial:
By including the Promiscuous publisher mixin, we can publish the model attributes:
# app/models/user.rb on the publisher app
class User
include Promiscuous::Publisher
publish :name, :email
endSimilarly to the publisher app, we can subscribe to the attributes:
# app/models/user.rb on the subscriber app
class User
include Promiscuous::Subscriber
subscribe :name, :email
after_create { Rails.logger.info "Hi #{name}!" }
endThe subscriber must listen for new data to arrive. Promiscuous has a worker that we can launch with the following command:
bundle exec promiscuous subscribeYou should start the subscriber first, otherwise the appropriate queues will not be created. From now on, you should see the queue in the RabbitMQ web admin page. Create a new user in the publisher's Rails console with:
User.create(:name => 'Yoda')`You should see the message "Hi Yoda!" appearing in the log file of the subscriber.
暂无开放 Issues,或尚未同步最近议题。