feat(Kernel): Demonstrate wiring up endpoints
Add just enough code to show how the kernel might use endpoint controllers as the uniform interface between transport and storage drivers. Change-Id: Id359986a4e45850266e64b06dae4544b52c8f93c Implements: blueprint endpoints
This commit is contained in:
parent
0651435b88
commit
8e72773c65
@ -1,18 +1,19 @@
|
|||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
# Copyright 2012 Rackspace, Inc.
|
# Copyright (c) 2013 Rackspace, Inc.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# not use this file except in compliance with the License. You may obtain
|
# you may not use this file except in compliance with the License.
|
||||||
# a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
# License for the specific language governing permissions and limitations
|
# implied.
|
||||||
# under the License.
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
"""Defines the Marconi Kernel
|
"""Defines the Marconi Kernel
|
||||||
|
|
||||||
@ -24,19 +25,21 @@ lifetimes.
|
|||||||
from ConfigParser import SafeConfigParser
|
from ConfigParser import SafeConfigParser
|
||||||
|
|
||||||
import marconi.transport.wsgi as wsgi
|
import marconi.transport.wsgi as wsgi
|
||||||
import marconi.storage.mongodb as mongodb
|
import marconi.storage.reference as reference
|
||||||
|
|
||||||
|
|
||||||
class Kernel(object):
|
class Kernel(object):
|
||||||
|
|
||||||
def __init__(self, config_file):
|
def __init__(self, config_file):
|
||||||
# @todo error handling
|
# TODO(kgriffs) Error handling
|
||||||
cfg = SafeConfigParser()
|
cfg = SafeConfigParser()
|
||||||
cfg.read(config_file)
|
cfg.read(config_file)
|
||||||
|
|
||||||
# @todo Determine driver types from cfg
|
# TODO(kgriffs) Determine driver types from cfg
|
||||||
self.storage = mongodb.Driver(cfg)
|
self.storage = reference.Driver(cfg)
|
||||||
self.transport = wsgi.Driver(self.storage, cfg)
|
self.transport = wsgi.Driver(cfg, self.storage.queue_controller,
|
||||||
|
self.storage.message_controller,
|
||||||
|
self.storage.claim_controller)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.transport.listen()
|
self.transport.listen()
|
||||||
|
@ -1 +1,3 @@
|
|||||||
""" Marconi Storage Drivers """
|
""" Marconi Storage Drivers """
|
||||||
|
|
||||||
|
from .driver_base import DriverBase # NOQA
|
||||||
|
36
marconi/storage/driver_base.py
Normal file
36
marconi/storage/driver_base.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
|
# Copyright (c) 2013 Rackspace, 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.
|
||||||
|
|
||||||
|
"""Implements the DriverBase abstract class for Marconi storage drivers."""
|
||||||
|
|
||||||
|
from abc import ABCMeta, abstractproperty
|
||||||
|
|
||||||
|
|
||||||
|
class DriverBase:
|
||||||
|
__metaclass__ = ABCMeta
|
||||||
|
|
||||||
|
@abstractproperty
|
||||||
|
def queue_controller(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractproperty
|
||||||
|
def message_controller(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractproperty
|
||||||
|
def claim_controller(self):
|
||||||
|
pass
|
@ -3,3 +3,5 @@
|
|||||||
Useful for automated testing and for prototyping storage driver concepts.
|
Useful for automated testing and for prototyping storage driver concepts.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from .driver import Driver # NOQA
|
||||||
|
39
marconi/storage/reference/driver.py
Normal file
39
marconi/storage/reference/driver.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
|
# Copyright (c) 2013 Rackspace, 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.
|
||||||
|
|
||||||
|
import marconi.storage as storage
|
||||||
|
|
||||||
|
|
||||||
|
class Driver(storage.DriverBase):
|
||||||
|
|
||||||
|
def __init__(self, cfg):
|
||||||
|
self._cfg = cfg
|
||||||
|
|
||||||
|
@property
|
||||||
|
def queue_controller(self):
|
||||||
|
# TODO(kgriffs): Create base classes for controllers in common/
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def message_controller(self):
|
||||||
|
# TODO(kgriffs): Create base classes for controllers in common/
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def claim_controller(self):
|
||||||
|
# TODO(kgriffs): Create base classes for controllers in common/
|
||||||
|
return None
|
@ -1,6 +1,6 @@
|
|||||||
[drivers]
|
[drivers]
|
||||||
transport = wsgi
|
transport = wsgi
|
||||||
storage = memory
|
storage = reference
|
||||||
|
|
||||||
[drivers:transport:wsgi]
|
[drivers:transport:wsgi]
|
||||||
port = 8888
|
port = 8888
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
# Copyright 2012 Rackspace, Inc.
|
# Copyright 2012 Rackspace, Inc.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
@ -13,12 +14,16 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import fixtures
|
import marconi.tests.util as util
|
||||||
import testtools
|
import marconi.common
|
||||||
|
|
||||||
|
|
||||||
class TestSimple(testtools.TestCase):
|
class TestSimple(util.TestSuite):
|
||||||
|
|
||||||
def test_simple(self):
|
def test_simple(self):
|
||||||
"""Doesn't really test much"""
|
"""Doesn't really test much"""
|
||||||
|
conf_file = self.conf_path('wsgi_reference.conf')
|
||||||
|
kernel = marconi.common.Kernel(conf_file)
|
||||||
|
transport = kernel.transport
|
||||||
|
wsgi_app = transport.app
|
||||||
self.assertTrue(True)
|
self.assertTrue(True)
|
||||||
|
@ -1 +1,3 @@
|
|||||||
""" Marconi Transport Modules """
|
""" Marconi Transport Modules """
|
||||||
|
|
||||||
|
from .driver_base import DriverBase # NOQA
|
||||||
|
30
marconi/transport/driver_base.py
Normal file
30
marconi/transport/driver_base.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
|
# Copyright (c) 2013 Rackspace, 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.
|
||||||
|
|
||||||
|
"""Implements the DriverBase abstract class for Marconi transport drivers."""
|
||||||
|
|
||||||
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
|
|
||||||
|
class DriverBase:
|
||||||
|
__metaclass__ = ABCMeta
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def listen():
|
||||||
|
# TODO(kgriffs): If this is all there is to DriverBase, do we
|
||||||
|
# even need it?
|
||||||
|
pass
|
@ -1 +1,3 @@
|
|||||||
""" WSGI Transport """
|
""" WSGI Transport Driver"""
|
||||||
|
|
||||||
|
from .driver import Driver # NOQA
|
||||||
|
44
marconi/transport/wsgi/driver.py
Normal file
44
marconi/transport/wsgi/driver.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
|
# Copyright (c) 2013 Rackspace, 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.
|
||||||
|
|
||||||
|
import marconi.transport as transport
|
||||||
|
|
||||||
|
|
||||||
|
class Driver(transport.DriverBase):
|
||||||
|
|
||||||
|
def __init__(self, cfg, queue_controller, message_controller,
|
||||||
|
claim_controller):
|
||||||
|
|
||||||
|
self._cfg = cfg
|
||||||
|
|
||||||
|
# E.g.:
|
||||||
|
#
|
||||||
|
# self._queue_controller.create(tenant_id, queue_name)
|
||||||
|
# self._queue_controller.set_metadata(tenant_id, queue_name, metadata)
|
||||||
|
#
|
||||||
|
self._queue_controller = queue_controller
|
||||||
|
self._message_controller = message_controller
|
||||||
|
self._claim_controller = claim_controller
|
||||||
|
|
||||||
|
# self.app = api = falcon.API()
|
||||||
|
|
||||||
|
def listen(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def app(self, env, start_response, exc_info=None):
|
||||||
|
"""This will be replace by falcon.API()"""
|
||||||
|
pass
|
Loading…
Reference in New Issue
Block a user