Move ConsistencyLevel to cassandra.__init__

This commit is contained in:
Tyler Hobbs
2013-05-06 14:42:03 -05:00
parent ffdcb99aa7
commit 0249496d2f
11 changed files with 50 additions and 61 deletions

View File

@@ -0,0 +1,36 @@
__version__ = '0.0.1-alpha'
__version_info__ = (0, 0, 1)
class ConsistencyLevel(object):
ANY = 0
ONE = 1
TWO = 2
THREE = 3
QUORUM = 4
ALL = 5
LOCAL_QUORUM = 6
EACH_QUORUM = 7
ConsistencyLevel.value_to_name = {
ConsistencyLevel.ANY: 'ANY',
ConsistencyLevel.ONE: 'ONE',
ConsistencyLevel.TWO: 'TWO',
ConsistencyLevel.THREE: 'THREE',
ConsistencyLevel.QUORUM: 'QUORUM',
ConsistencyLevel.ALL: 'ALL',
ConsistencyLevel.LOCAL_QUORUM: 'LOCAL_QUORUM',
ConsistencyLevel.EACH_QUORUM: 'EACH_QUORUM'
}
ConsistencyLevel.name_to_value = {
'ANY': ConsistencyLevel.ANY,
'ONE': ConsistencyLevel.ONE,
'TWO': ConsistencyLevel.TWO,
'THREE': ConsistencyLevel.THREE,
'QUORUM': ConsistencyLevel.QUORUM,
'ALL': ConsistencyLevel.ALL,
'LOCAL_QUORUM': ConsistencyLevel.LOCAL_QUORUM,
'EACH_QUORUM': ConsistencyLevel.EACH_QUORUM
}

View File

@@ -6,8 +6,9 @@ import Queue
import weakref
from functools import partial
from cassandra import ConsistencyLevel
from cassandra.connection import Connection, ConnectionException
from cassandra.decoder import (ConsistencyLevel, QueryMessage, ResultMessage,
from cassandra.decoder import (QueryMessage, ResultMessage,
ErrorMessage, ReadTimeoutErrorMessage,
WriteTimeoutErrorMessage,
UnavailableErrorMessage,

View File

@@ -8,12 +8,11 @@ import socket
from threading import RLock, Event, Lock, Thread
import traceback
from cassandra import ConsistencyLevel
from cassandra.marshal import (int8_unpack, int32_unpack)
from cassandra.decoder import (OptionsMessage, ReadyMessage, AuthenticateMessage,
StartupMessage, ErrorMessage, CredentialsMessage,
QueryMessage, ResultMessage, ConsistencyLevel,
decode_response)
QueryMessage, ResultMessage, decode_response)
log = logging.getLogger(__name__)

View File

@@ -20,6 +20,7 @@ try:
except ImportError:
from StringIO import StringIO # ignore flake8 warning: # NOQA
from cassandra import ConsistencyLevel
from cassandra.marshal import (int32_pack, int32_unpack, uint16_pack, uint16_unpack,
int8_pack, int8_unpack)
from cassandra.types import lookup_cqltype
@@ -45,40 +46,6 @@ def warn(msg):
print msg
class ConsistencyLevel(object):
ANY = 0
ONE = 1
TWO = 2
THREE = 3
QUORUM = 4
ALL = 5
LOCAL_QUORUM = 6
EACH_QUORUM = 7
ConsistencyLevel.value_to_name = {
ConsistencyLevel.ANY: 'ANY',
ConsistencyLevel.ONE: 'ONE',
ConsistencyLevel.TWO: 'TWO',
ConsistencyLevel.THREE: 'THREE',
ConsistencyLevel.QUORUM: 'QUORUM',
ConsistencyLevel.ALL: 'ALL',
ConsistencyLevel.LOCAL_QUORUM: 'LOCAL_QUORUM',
ConsistencyLevel.EACH_QUORUM: 'EACH_QUORUM'
}
ConsistencyLevel.name_to_value = {
'ANY': ConsistencyLevel.ANY,
'ONE': ConsistencyLevel.ONE,
'TWO': ConsistencyLevel.TWO,
'THREE': ConsistencyLevel.THREE,
'QUORUM': ConsistencyLevel.QUORUM,
'ALL': ConsistencyLevel.ALL,
'LOCAL_QUORUM': ConsistencyLevel.LOCAL_QUORUM,
'EACH_QUORUM': ConsistencyLevel.EACH_QUORUM
}
class PreparedResult:
def __init__(self, queryid, param_metadata):
self.queryid = queryid

View File

@@ -1,19 +1,3 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
import struct
def _make_packer(format_string):

View File

@@ -2,7 +2,7 @@ from itertools import islice, cycle, groupby, repeat
from random import randint
from threading import RLock
from decoder import ConsistencyLevel
from cassandra import ConsistencyLevel
class HostDistance(object):

View File

@@ -1,6 +1,6 @@
import struct
from decoder import ConsistencyLevel
from cassandra import ConsistencyLevel
class Query(object):

View File

@@ -1,11 +1,12 @@
import unittest
from mock import Mock, ANY
from cassandra import ConsistencyLevel
from cassandra.cluster import Cluster, Session, ResponseFuture, NoHostAvailable
from cassandra.connection import ConnectionException
from cassandra.decoder import (ReadTimeoutErrorMessage, WriteTimeoutErrorMessage,
UnavailableErrorMessage, ResultMessage, QueryMessage,
OverloadedErrorMessage, ConsistencyLevel)
OverloadedErrorMessage)
from cassandra.policies import RetryPolicy
from cassandra.pool import NoConnectionsAvailable
from cassandra.query import SimpleStatement

View File

@@ -2,7 +2,8 @@ import unittest
from functools import partial
from threading import Thread, Event
from cassandra.decoder import QueryMessage, ConsistencyLevel
from cassandra import ConsistencyLevel
from cassandra.decoder import QueryMessage
from cassandra.connection import Connection
class ConnectionTest(unittest.TestCase):

View File

@@ -1,7 +1,7 @@
import unittest
from cassandra.decoder import ResultMessage
from cassandra.cluster import _ControlConnection, Cluster
from cassandra.cluster import ControlConnection, Cluster
from cassandra.pool import Host
from cassandra.policies import SimpleConvictionPolicy
@@ -109,7 +109,7 @@ class ControlConnectionTest(unittest.TestCase):
self.connection = MockConnection()
self.time = FakeTime()
self.control_connection = _ControlConnection(self.cluster)
self.control_connection = ControlConnection(self.cluster)
self.control_connection._connection = self.connection
self.control_connection._time = self.time

View File

@@ -1,7 +1,7 @@
import unittest
from threading import Thread
from cassandra.decoder import ConsistencyLevel
from cassandra import ConsistencyLevel
from cassandra.policies import (RoundRobinPolicy, DCAwareRoundRobinPolicy,
SimpleConvictionPolicy, HostDistance,
ExponentialReconnectionPolicy, RetryPolicy,