PYTHON-525 Move SERVER_TYPE to its own file.

This commit is contained in:
A. Jesse Jiryu Davis 2014-08-08 12:15:27 -04:00
parent 51daea7eb2
commit 590c68d287
9 changed files with 36 additions and 14 deletions

View File

@ -17,8 +17,9 @@
from collections import namedtuple
from pymongo import common
from pymongo.server_type import SERVER_TYPE
from pymongo.errors import ConfigurationError
from pymongo.server_description import ServerDescription, SERVER_TYPE
from pymongo.server_description import ServerDescription
CLUSTER_TYPE = namedtuple('ClusterType', ['Single', 'ReplicaSetNoPrimary',

View File

@ -15,16 +15,10 @@
"""Parse a response to the 'ismaster' command."""
import itertools
from collections import namedtuple
from bson.py3compat import imap
from pymongo import common
SERVER_TYPE = namedtuple('ServerType',
['Unknown', 'Mongos', 'RSPrimary', 'RSSecondary',
'RSArbiter', 'RSOther', 'RSGhost',
'Standalone'])(*range(8))
from pymongo.server_type import SERVER_TYPE
def _get_server_type(doc):

View File

@ -21,7 +21,8 @@ import time
import weakref
from pymongo import common, helpers, message, thread_util
from pymongo.ismaster import IsMaster, SERVER_TYPE
from pymongo.server_type import SERVER_TYPE
from pymongo.ismaster import IsMaster
from pymongo.read_preferences import MovingAverage
from pymongo.server_description import ServerDescription

View File

@ -14,7 +14,7 @@
"""Communicate with one MongoDB server in a cluster."""
from pymongo.ismaster import SERVER_TYPE
from pymongo.server_type import SERVER_TYPE
from pymongo.response import Response, ExhaustResponse

View File

@ -14,7 +14,8 @@
"""Represent one server in the cluster."""
from pymongo.ismaster import IsMaster, SERVER_TYPE
from pymongo.server_type import SERVER_TYPE
from pymongo.ismaster import IsMaster
class ServerDescription(object):

View File

@ -14,7 +14,7 @@
"""Criteria to select some ServerDescriptions out of a list."""
from pymongo.ismaster import SERVER_TYPE
from pymongo.server_type import SERVER_TYPE
def any_server_selector(server_descriptions):

23
pymongo/server_type.py Normal file
View File

@ -0,0 +1,23 @@
# Copyright 2014 MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Type codes for MongoDB servers."""
from collections import namedtuple
SERVER_TYPE = namedtuple('ServerType',
['Unknown', 'Mongos', 'RSPrimary', 'RSSecondary',
'RSArbiter', 'RSOther', 'RSGhost',
'Standalone'])(*range(8))

View File

@ -23,6 +23,7 @@ import threading
from bson.py3compat import imap
from pymongo import common
from pymongo.server_type import SERVER_TYPE
from pymongo.cluster import Cluster
from pymongo.cluster_description import CLUSTER_TYPE
from pymongo.errors import (ConfigurationError,
@ -31,7 +32,7 @@ from pymongo.errors import (ConfigurationError,
from pymongo.ismaster import IsMaster
from pymongo.monitor import Monitor
from pymongo.read_preferences import MovingAverage
from pymongo.server_description import ServerDescription, SERVER_TYPE
from pymongo.server_description import ServerDescription
from pymongo.server_selectors import (any_server_selector,
writable_server_selector)
from pymongo.settings import ClusterSettings

View File

@ -18,9 +18,10 @@ import sys
sys.path[0:0] = [""]
from pymongo.server_type import SERVER_TYPE
from pymongo.ismaster import IsMaster
from pymongo.read_preferences import MovingAverage
from pymongo.server_description import ServerDescription, SERVER_TYPE
from pymongo.server_description import ServerDescription
from test import unittest
address = ('localhost', 27017)