Commit 7a4244d7 authored by Jacek Furmankiewicz's avatar Jacek Furmankiewicz

initial steps with tzZMQ + switch to IDEA IntelliJ

parent 1d843ea2
...@@ -3,3 +3,4 @@ build ...@@ -3,3 +3,4 @@ build
dist dist
*.egg-info *.egg-info
.settings .settings
*plugin.xml
corepost
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value>
<option name="LINE_SEPARATOR" value="&#10;" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="15" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="5" />
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<emptyLine />
<package name="" withSubpackages="true" static="true" />
</value>
</option>
<option name="RIGHT_MARGIN" value="140" />
<option name="JD_P_AT_EMPTY_LINES" value="false" />
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="Gherkin">
<indentOptions>
<option name="INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_ASSIGNMENT" value="true" />
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_THROWS_LIST" value="true" />
<option name="ALIGN_MULTILINE_METHOD_BRACKETS" value="true" />
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
<option name="ALIGN_GROUP_FIELD_DECLARATIONS" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="PREFER_PARAMETERS_WRAP" value="true" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="RESOURCE_LIST_WRAP" value="1" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="THROWS_LIST_WRAP" value="1" />
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="TERNARY_OPERATION_WRAP" value="1" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="ASSIGNMENT_WRAP" value="1" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
</codeStyleSettings>
<codeStyleSettings language="SQL">
<indentOptions>
<option name="INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="yaml">
<indentOptions>
<option name="INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
</value>
</option>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="compAPI" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="?*.properties" />
<entry name="?*.xml" />
<entry name="?*.gif" />
<entry name="?*.png" />
<entry name="?*.jpeg" />
<entry name="?*.jpg" />
<entry name="?*.html" />
<entry name="?*.dtd" />
<entry name="?*.tld" />
<entry name="?*.ftl" />
</wildcardResourcePatterns>
<annotationProcessing enabled="false" useClasspath="true" />
</component>
</project>
<component name="ProjectDictionaryState">
<dictionary name="dok" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="true" defaultCharsetForPropertiesFiles="UTF-8" />
</project>
<component name="InspectionProjectProfileManager">
<profile version="1.0" is_locked="false">
<option name="myName" value="Project Default" />
<option name="myLocal" value="false" />
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" />
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerAPISettings">
<option name="MAXIMUM_HEAP_SIZE" value="256" />
</component>
<component name="CopyrightManager" default="">
<module2copyright />
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State>
<id />
</State>
<State>
<id>AOP</id>
</State>
<State>
<id>Abstraction issues</id>
</State>
<State>
<id>Ant inspections</id>
</State>
<State>
<id>Assignment issues</id>
</State>
<State>
<id>Assignment issuesGroovy</id>
</State>
<State>
<id>Bash</id>
</State>
<State>
<id>CSS</id>
</State>
<State>
<id>Class metrics</id>
</State>
<State>
<id>Class structure</id>
</State>
<State>
<id>Code style issues</id>
</State>
<State>
<id>Concurrency annotation issues</id>
</State>
<State>
<id>Control FlowGroovy</id>
</State>
<State>
<id>Control flow issues</id>
</State>
<State>
<id>Data Flow IssuesGroovy</id>
</State>
<State>
<id>Data flow issues</id>
</State>
<State>
<id>Declaration redundancy</id>
</State>
<State>
<id>Declaration redundancyGroovy</id>
</State>
<State>
<id>Encapsulation issues</id>
</State>
<State>
<id>Error handling</id>
</State>
<State>
<id>Error handlingGroovy</id>
</State>
<State>
<id>General</id>
</State>
<State>
<id>Groovy</id>
</State>
<State>
<id>HTML</id>
</State>
<State>
<id>IDEA Platform Inspections</id>
</State>
<State>
<id>Imports</id>
</State>
<State>
<id>Initialization issues</id>
</State>
<State>
<id>Internationalization issues</id>
</State>
<State>
<id>J2ME issues</id>
</State>
<State>
<id>JSP Inspections</id>
</State>
<State>
<id>JUnit issues</id>
</State>
<State>
<id>Java EE issues</id>
</State>
<State>
<id>Java language level issues</id>
</State>
<State>
<id>Java language level migration aids</id>
</State>
<State>
<id>JavaBeans issues</id>
</State>
<State>
<id>Javadoc issues</id>
</State>
<State>
<id>Language Injection</id>
</State>
<State>
<id>Logging issues</id>
</State>
<State>
<id>Memory issues</id>
</State>
<State>
<id>Method MetricsGroovy</id>
</State>
<State>
<id>Method metrics</id>
</State>
<State>
<id>Naming conventions</id>
</State>
<State>
<id>Numeric issues</id>
</State>
<State>
<id>Performance issues</id>
</State>
<State>
<id>Portability issues</id>
</State>
<State>
<id>Potentially confusing code constructsGroovy</id>
</State>
<State>
<id>Probable bugs</id>
</State>
<State>
<id>Probable bugsGroovy</id>
</State>
<State>
<id>Properties Files</id>
</State>
<State>
<id>RELAX NG</id>
</State>
<State>
<id>SQL</id>
</State>
<State>
<id>Security issues</id>
</State>
<State>
<id>Serialization issues</id>
</State>
<State>
<id>Spring Model</id>
</State>
<State>
<id>TestNG</id>
</State>
<State>
<id>Threading issues</id>
</State>
<State>
<id>Threading issuesGroovy</id>
</State>
<State>
<id>Validity issuesGroovy</id>
</State>
<State>
<id>Verbose or redundant code constructs</id>
</State>
<State>
<id>Visibility issues</id>
</State>
<State>
<id>Web Services Inspections</id>
</State>
<State>
<id>XML</id>
</State>
</expanded-state>
</profile-state>
</entry>
</component>
<component name="ProjectResources">
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="Python 2.7" project-jdk-type="Python SDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="SvnConfiguration" maxAnnotateRevisions="500" myUseAcceleration="nothing" myAutoUpdateAfterCommit="false" cleanupOnStartRun="false">
<option name="USER" value="" />
<option name="PASSWORD" value="" />
<option name="mySSHConnectionTimeout" value="30000" />
<option name="mySSHReadTimeout" value="30000" />
<option name="LAST_MERGED_REVISION" />
<option name="MERGE_DRY_RUN" value="false" />
<option name="MERGE_DIFF_USE_ANCESTRY" value="true" />
<option name="UPDATE_LOCK_ON_DEMAND" value="false" />
<option name="IGNORE_SPACES_IN_MERGE" value="false" />
<option name="DETECT_NESTED_COPIES" value="true" />
<option name="CHECK_NESTED_FOR_QUICK_MERGE" value="false" />
<option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
<option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
<option name="FORCE_UPDATE" value="false" />
<configuration useDefault="false">$USER_HOME$/.subversion_IDEA</configuration>
<myIsUseDefaultProxy>false</myIsUseDefaultProxy>
</component>
<component name="ValidationConfiguration">
<option name="VALIDATE_ON_BUILD" value="true" />
<option name="VALIDATORS">
<map>
<entry key="EJB Validator" value="true" />
<entry key="JPA Validator" value="true" />
<entry key="Jasper Validator" value="true" />
<entry key="Spring Model Validator" value="true" />
<entry key="Web Xml Validator" value="true" />
</map>
</option>
</component>
<component name="VssConfiguration">
<option name="CLIENT_PATH" value="" />
<option name="SRCSAFEINI_PATH" value="" />
<option name="USER_NAME" value="" />
<option name="PWD" value="" />
<CheckoutOptions>
<option name="COMMENT" value="" />
<option name="DO_NOT_GET_LATEST_VERSION" value="false" />
<option name="REPLACE_WRITABLE" value="false" />
<option name="RECURSIVE" value="false" />
</CheckoutOptions>
<CheckinOptions>
<option name="COMMENT" value="" />
<option name="KEEP_CHECKED_OUT" value="false" />
<option name="RECURSIVE" value="false" />
</CheckinOptions>
<AddOptions>
<option name="STORE_ONLY_LATEST_VERSION" value="false" />
<option name="CHECK_OUT_IMMEDIATELY" value="false" />
</AddOptions>
<UndocheckoutOptions>
<option name="MAKE_WRITABLE" value="false" />
<option name="REPLACE_LOCAL_COPY" value="2" />
<option name="RECURSIVE" value="false" />
</UndocheckoutOptions>
<GetOptions>
<option name="REPLACE_WRITABLE" value="0" />
<option name="MAKE_WRITABLE" value="false" />
<option name="ANSWER_NEGATIVELY" value="false" />
<option name="ANSWER_POSITIVELY" value="false" />
<option name="RECURSIVE" value="false" />
<option name="VERSION" />
</GetOptions>
</component>
<component name="WebServicesPlugin" addRequiredLibraries="true" />
<component name="masterDetails">
<states>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<last-edited>1.7</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>JDK 1.7</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.20000002" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Corepost.iml" filepath="$PROJECT_DIR$/Corepost.iml" />
</modules>
</component>
</project>
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
__author__ = 'jacekf'
try:
import txZMQ
except ImportError as ex:
print "You must have ZeroMQ and txZMQ installed"
raise ex
from corepost import Response, IRESTResource
from corepost.enums import Http
from corepost.routing import UrlRouter, RequestRouter
from enums import MediaType
from formencode import FancyValidator, Invalid
from twisted.internet import reactor
from twisted.internet.defer import Deferred
from twisted.web.resource import Resource
from twisted.web.server import Site, NOT_DONE_YET
from zope.interface import implements
class ZMQResource(Resource):
"""
Responsible for intercepting HTTP requests and marshalling them via ZeroMQ to responders in the process pool
"""
isLeaf = True
implements(IRESTResource)
def __init__(self):
'''
Constructor
'''
Resource.__init__(self)
def render(self, request):
"""Posts request to ZeroMQ and waits for response"""
pass
class ZMQResponder:
"""
Responsible for processing an incoming request via ZeroMQ and responding via a REST API as if it were a direct HTTP request
"""
def __init__(self,services=(),schema=None,filters=()):
'''
Constructor
'''
self.services = services
self.__router = RequestRouter(self,schema,filters)
'''
Multicore module
@author: jacekf
'''
try:
import txZMQ
except ImportError as ex:
print "You need to have txZMQ and ZeroMQ installed in order to use multicore support in Corepost"
raise ex
'''
ZeroMQ resource
@author: jacekf
'''
from corepost.web import RESTResource, route
from corepost.enums import Http
from corepost.filters import IRequestFilter, IResponseFilter
from zope.interface import implements
from multiprocessing import Pool
class TestService:
@route("/")
def forward(self,request):
return ""
def startClient():
return "TEST"
def run_app_multicore():
#start the ZeroMQ client
pool = Pool(processes=4)
#start the server
app = RESTResource((TestService(),))
app.run(8090)
if __name__ == "__main__":
run_app_multicore()
\ No newline at end of file
...@@ -6,6 +6,17 @@ Server tests ...@@ -6,6 +6,17 @@ Server tests
from corepost import Response, NotFoundException, AlreadyExistsException from corepost import Response, NotFoundException, AlreadyExistsException
from corepost.web import RESTResource, route, Http from corepost.web import RESTResource, route, Http
from twisted.cred.portal import IRealm, Portal
from twisted.cred.checkers import FilePasswordDB
from twisted.web.static import File
from twisted.web.resource import IResource
from twisted.web.guard import HTTPAuthSessionWrapper, BasicCredentialFactory
from zope.interface import implements
# Security
# Database
class DB(): class DB():
"""Fake in-memory DB for testing""" """Fake in-memory DB for testing"""
customers = {} customers = {}
...@@ -128,7 +139,6 @@ class CustomerAddressRESTService(): ...@@ -128,7 +139,6 @@ class CustomerAddressRESTService():
c.addresses = {} c.addresses = {}
return Response(200) return Response(200)
def run_rest_app(): def run_rest_app():
app = RESTResource((CustomerRESTService(),CustomerAddressRESTService())) app = RESTResource((CustomerRESTService(),CustomerAddressRESTService()))
app.run(8085) app.run(8085)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment