Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mongoid/moped
...
head fork: mongoid/moped
  • 7 commits
  • 16 files changed
  • 0 commit comments
  • 2 contributors
View
8 lib/moped/cluster.rb
@@ -46,14 +46,14 @@ def refresh(nodes_to_refresh = @nodes)
refreshed_nodes << node unless refreshed_nodes.include?(node)
# Now refresh any newly discovered peer nodes.
- (node.peers - @nodes).each &refresh_node
+ (node.peers - @nodes).each(&refresh_node)
rescue Errors::ConnectionFailure
# We couldn't connect to the node, so don't do anything with it.
end
end
end
- nodes_to_refresh.each &refresh_node
+ nodes_to_refresh.each(&refresh_node)
refreshed_nodes.to_a
end
@@ -75,7 +75,7 @@ def nodes
available.concat refresh(needs_refresh)
# Now return all the nodes that are available.
- available.reject &:down?
+ available.reject(&:down?)
end
# Yields the replica set's primary node to the provided block. This method
@@ -138,7 +138,7 @@ def auth
private
def initialize_copy(_)
- @nodes = @nodes.map &:dup
+ @nodes = @nodes.map(&:dup)
end
end
View
14 lib/moped/indexes.rb
@@ -4,9 +4,17 @@ class Indexes
private
- attr_reader :database
- attr_reader :collection_name
- attr_reader :namespace
+ def database
+ @database
+ end
+
+ def collection_name
+ @collection_name
+ end
+
+ def namespace
+ @namespace
+ end
def initialize(database, collection_name)
@database = database
View
4 lib/moped/node.rb
@@ -18,6 +18,10 @@ def initialize(address)
@resolved_address = "#{@ip_address}:#{@port}"
@timeout = 5
+ @down_at = nil
+ @refreshed_at = nil
+ @primary = nil
+ @secondary = nil
end
def command(database, cmd, options = {})
View
1  lib/moped/protocol/delete.rb
@@ -76,6 +76,7 @@ def initialize(database, collection, selector, options = {})
@flags = options[:flags]
end
+ undef op_code
# @return [Number] OP_DELETE operation code (2006)
def op_code
2006
View
1  lib/moped/protocol/get_more.rb
@@ -43,6 +43,7 @@ class GetMore
# @return [Number] the id of the cursor to get more documents from
int64 :cursor_id
+ undef op_code
# @return [Number] OP_GETMORE operation code (2005)
def op_code
2005
View
1  lib/moped/protocol/insert.rb
@@ -46,6 +46,7 @@ class Insert
# @return [Array<Hash>] the documents to insert
document :documents, type: :array
+ undef op_code
# @return [Number] OP_INSERT operation code (2002)
def op_code
2002
View
1  lib/moped/protocol/kill_cursors.rb
@@ -35,6 +35,7 @@ class KillCursors
# @return [Array] the cursor ids to kill
int64 :cursor_ids, type: :array
+ undef op_code
# @return [Number] OP_KILL_CURSORS operation code (2007)
def op_code
2007
View
2  lib/moped/protocol/message.rb
@@ -152,8 +152,6 @@ def serialize_#{name}(buffer)
# @param [String] name the name of this field
# @param [Hash{Symbol => Number}] flags the flags for this flag field
def flags(name, flag_map = {})
- attr_writer name
-
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{name}
@#{name} ||= []
View
1  lib/moped/protocol/query.rb
@@ -64,6 +64,7 @@ class Query
# @return [Hash, nil] the fields to include in the reply
document :fields, :optional => true
+ undef op_code
# @return [Number] OP_QUERY operation code (2004)
def op_code
2004
View
1  lib/moped/protocol/update.rb
@@ -56,6 +56,7 @@ class Update
# @return [Hash] the updates to apply
document :update
+ undef op_code
# @return [Number] OP_UPDATE operation code (2001)
def op_code
2001
View
14 spec/moped/cluster_spec.rb
@@ -7,7 +7,7 @@
context "when no nodes are available" do
before do
- @replica_set.nodes.each &:stop
+ @replica_set.nodes.each(&:stop)
end
describe "#with_primary" do
@@ -96,7 +96,7 @@
context "and all secondaries are down" do
before do
- @secondaries.each &:stop
+ @secondaries.each(&:stop)
end
describe "#with_primary" do
@@ -187,7 +187,7 @@
context "and all secondaries are down" do
before do
- @secondaries.each &:stop
+ @secondaries.each(&:stop)
end
describe "#with_primary" do
@@ -217,7 +217,7 @@
context "and all secondaries are down" do
before do
replica_set.refresh
- @secondaries.each &:stop
+ @secondaries.each(&:stop)
replica_set.refresh
end
@@ -232,7 +232,7 @@
context "when a secondary node comes back up" do
before do
- @secondaries.each &:restart
+ @secondaries.each(&:restart)
end
describe "#with_secondary" do
@@ -309,7 +309,7 @@
describe "logging in with valid credentials" do
it "logs in and processes commands" do
- session.login *Support::MongoHQ.auth_credentials
+ session.login(*Support::MongoHQ.auth_credentials)
session.command(ping: 1).should eq("ok" => 1)
end
end
@@ -326,7 +326,7 @@
describe "logging in with valid credentials and then logging out" do
before do
- session.login *Support::MongoHQ.auth_credentials
+ session.login(*Support::MongoHQ.auth_credentials)
session.command(ping: 1).should eq("ok" => 1)
end
View
2  spec/moped/query_spec.rb
@@ -329,7 +329,7 @@
context "and no secondaries are available" do
before do
- @secondaries.each &:stop
+ @secondaries.each(&:stop)
end
it "queries the primary node" do
View
2  spec/moped/session_spec.rb
@@ -38,7 +38,7 @@
end
it "does not modify the original session" do
- other = session.with(database: "other")
+ session.with(database: "other")
session.options[:database].should eq "moped_test"
end
end
View
4 spec/support/mongohq.rb
@@ -20,7 +20,7 @@ def replica_set_database
def replica_set_session(auth = true)
session = Moped::Session.new replica_set_seeds, database: replica_set_database
- session.login *replica_set_credentials if auth
+ session.login(*replica_set_credentials) if auth
session
end
@@ -42,7 +42,7 @@ def auth_database
def auth_session(auth = true)
session = Moped::Session.new auth_seeds, database: auth_database
- session.login *auth_credentials if auth
+ session.login(*auth_credentials) if auth
session
end
View
16 spec/support/replica_set_simulator.rb
@@ -9,7 +9,7 @@ class ReplicaSetSimulator
module Helpers
def self.included(context)
context.let :seeds do
- @replica_set.nodes.map &:address
+ @replica_set.nodes.map(&:address)
end
end
end
@@ -23,7 +23,7 @@ def self.configure(config)
end
config.after :each, replica_set: true do
- @replica_set.nodes.each &:restart
+ @replica_set.nodes.each(&:restart)
end
config.after :all, replica_set: true do
@@ -48,7 +48,7 @@ def initialize(nodes = 3)
# Start the mock replica set.
def start
- @nodes.each &:start
+ @nodes.each(&:start)
@worker = Thread.start do
Thread.abort_on_exception = true
catch(:shutdown) do
@@ -73,7 +73,7 @@ def initiate
primary, *secondaries = @nodes.shuffle
primary.promote
- secondaries.each &:demote
+ secondaries.each(&:demote)
return primary, secondaries
end
@@ -81,7 +81,7 @@ def initiate
# Shut down the mock replica set.
def stop
@manager.shutdown
- @nodes.each &:stop
+ @nodes.each(&:stop)
end
class Node
@@ -96,6 +96,7 @@ def initialize(set, port)
@host = Socket.gethostname
@port = port
+ @hiccup_on_next_message = nil
end
def ==(other)
@@ -243,6 +244,7 @@ def initialize(servers)
@timeout = 0.1
@servers = servers
@clients = []
+ @shutdown = nil
end
def shutdown
@@ -260,8 +262,8 @@ def next_client
throw :shutdown if @shutdown
begin
- servers = @servers.reject &:closed?
- clients = @clients.reject &:closed?
+ servers = @servers.reject(&:closed?)
+ clients = @clients.reject(&:closed?)
Moped.logger.debug "replica_set: selecting on connections"
readable, _, errors = Kernel.select(servers + clients, nil, clients, @timeout)
rescue IOError, Errno::EBADF, TypeError
View
1  spec/support/stats.rb
@@ -45,6 +45,7 @@ def logging(operations, &block)
_logging(operations, &block)
end
EOS
+ @stats = nil
end
end

No commit comments for this range

Something went wrong with that request. Please try again.