Testing infrastructure in place

This commit is contained in:
2019-05-03 12:29:42 +02:00
committed by Lionel Sambuc
parent 1a923c5477
commit 455f83c58b
8 changed files with 526 additions and 136 deletions

316
.idea/workspace.xml generated
View File

@@ -13,15 +13,11 @@
</component>
<component name="ChangeListManager">
<list default="true" id="b0ee3aed-2536-4f3a-8c92-83bfe0a44195" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" />
<change afterPath="$PROJECT_DIR$/src/solr_api/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Cargo.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/solr_api/admin.rs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/solr_api/context.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/solr_api.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/solr_api/select.rs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/solr_api/service.rs" beforeDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@@ -47,34 +43,57 @@
<select />
</component>
<component name="FileEditorManager">
<splitter split-orientation="vertical" split-proportion="0.2">
<split-first>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/Cargo.toml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="57">
<caret line="8" selection-start-line="8" selection-end-line="8" />
</state>
</provider>
</entry>
</file>
</leaf>
</split-first>
<split-second>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="676">
<caret line="69" column="35" selection-start-line="69" selection-start-column="35" selection-end-line="69" selection-end-column="35" />
<state relative-caret-position="300">
<caret line="20" selection-start-line="20" selection-end-line="20" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/solr_api/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="577">
<caret line="40" selection-start-line="40" selection-end-line="40" />
<folding>
<element signature="e#2490#2808#0" />
<element signature="e#3600#3745#0" />
<element signature="e#4720#4721#0" expanded="true" />
<element signature="e#4750#4751#0" expanded="true" />
<element signature="e#4109#4111#0" />
<element signature="e#5113#5114#0" expanded="true" />
<element signature="e#5147#5148#0" expanded="true" />
<element signature="e#5198#5199#0" expanded="true" />
<element signature="e#5257#5258#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/solr_api/admin.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="3840">
<caret line="340" column="35" selection-start-line="340" selection-start-column="35" selection-end-line="340" selection-end-column="35" />
<folding>
<element signature="e#46#592#0" />
<element signature="e#594#1142#0" />
<element signature="e#1144#1692#0" />
<element signature="e#1694#2242#0" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/solr_api/select.rs">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
</leaf>
</split-second>
</splitter>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
@@ -105,6 +124,7 @@
<find>K: Hash</find>
<find>HasQueryParams</find>
<find>lock</find>
<find>i32</find>
</findStrings>
<replaceStrings>
<replace>cores::Response</replace>
@@ -113,6 +133,7 @@
<replace>Ctx</replace>
<replace>K: Hash + Eq</replace>
<replace>HasQueryParams&lt;K, V&gt;</replace>
<replace>SharedState</replace>
</replaceStrings>
</component>
<component name="Git.Settings">
@@ -144,10 +165,12 @@
<option value="$PROJECT_DIR$/src/solr_api/select.rs" />
<option value="$PROJECT_DIR$/src/solr_api/context.rs" />
<option value="$PROJECT_DIR$/src/solr_api/query_params.rs" />
<option value="$PROJECT_DIR$/src/solr_api/mod.rs" />
<option value="$PROJECT_DIR$/src/solr_api/service.rs" />
<option value="$PROJECT_DIR$/src/solr_api.rs" />
<option value="$PROJECT_DIR$/Cargo.toml" />
<option value="$PROJECT_DIR$/src/solr_api/tests.rs" />
<option value="$PROJECT_DIR$/src/solr_api/test.rs" />
<option value="$PROJECT_DIR$/src/solr_api/mod.rs" />
<option value="$PROJECT_DIR$/src/main.rs" />
</list>
</option>
@@ -156,8 +179,8 @@
<option name="directoryName" value="aMXmNNVU" />
</component>
<component name="ProjectFrameBounds">
<option name="x" value="1463" />
<option name="y" value="23" />
<option name="x" value="552" />
<option name="y" value="44" />
<option name="width" value="1733" />
<option name="height" value="1282" />
</component>
@@ -179,6 +202,12 @@
<item name="service_test" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="service_test" type="b2602c69:ProjectViewProjectNode" />
<item name="service_test" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="solr_api" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
@@ -192,7 +221,7 @@
<property name="org.rust.cargo.project.model.PROJECT_DISCOVERY" value="true" />
<property name="org.rust.hideToolchainNotifications" value="true" />
<property name="restartRequiresConfirmation" value="false" />
<property name="settings.editor.selected.configurable" value="reference.settingsdialog.IDE.editor.colors" />
<property name="settings.editor.selected.configurable" value="dynamic.analysis.tools.valgrind" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
@@ -212,6 +241,36 @@
</option>
</component>
<component name="RunManager" selected="Cargo Command.run-debug">
<configuration name="Test solr_api::tests" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="channel" value="DEFAULT" />
<option name="command" value="test --package service_test --bin service_test solr_api::tests" />
<option name="allFeatures" value="false" />
<option name="nocapture" value="false" />
<option name="backtrace" value="SHORT" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<method v="2" />
</configuration>
<configuration name="Test solr_api::tests::default_no_path" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="channel" value="DEFAULT" />
<option name="command" value="test --package service_test --bin service_test solr_api::tests::default_no_path -- --exact" />
<option name="allFeatures" value="false" />
<option name="nocapture" value="false" />
<option name="backtrace" value="SHORT" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<method v="2" />
</configuration>
<configuration name="Test solr_api::tests::default_slash" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="channel" value="DEFAULT" />
<option name="command" value="test --package service_test --bin service_test solr_api::tests::default_slash -- --exact" />
<option name="allFeatures" value="false" />
<option name="nocapture" value="false" />
<option name="backtrace" value="SHORT" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<method v="2" />
</configuration>
<configuration name="build-debug" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="channel" value="DEFAULT" />
<option name="command" value="build" />
@@ -265,7 +324,17 @@
<item itemvalue="Cargo Command.run-debug" />
<item itemvalue="Cargo Command.build" />
<item itemvalue="Cargo Command.run" />
<item itemvalue="Cargo Command.Test solr_api::tests" />
<item itemvalue="Cargo Command.Test solr_api::tests::default_no_path" />
<item itemvalue="Cargo Command.Test solr_api::tests::default_slash" />
</list>
<recent_temporary>
<list>
<item itemvalue="Cargo Command.Test solr_api::tests" />
<item itemvalue="Cargo Command.Test solr_api::tests::default_slash" />
<item itemvalue="Cargo Command.Test solr_api::tests::default_no_path" />
</list>
</recent_temporary>
</component>
<component name="RustProjectSettings">
<option name="runRustfmtOnSave" value="true" />
@@ -275,16 +344,48 @@
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TestHistory">
<history-entry file="Test_solr_api__tests__default_no_path - 2019.05.02 at 14h 53m 55s.xml">
<configuration name="Test solr_api::tests::default_no_path" configurationId="CargoCommandRunConfiguration" />
</history-entry>
<history-entry file="Test_solr_api__tests__default_slash - 2019.05.02 at 14h 54m 41s.xml">
<configuration name="Test solr_api::tests::default_slash" configurationId="CargoCommandRunConfiguration" />
</history-entry>
<history-entry file="Test_solr_api__tests - 2019.05.02 at 14h 54m 50s.xml">
<configuration name="Test solr_api::tests" configurationId="CargoCommandRunConfiguration" />
</history-entry>
<history-entry file="Test_solr_api__tests - 2019.05.02 at 14h 55m 27s.xml">
<configuration name="Test solr_api::tests" configurationId="CargoCommandRunConfiguration" />
</history-entry>
<history-entry file="Test_solr_api__tests - 2019.05.02 at 15h 00m 22s.xml">
<configuration name="Test solr_api::tests" configurationId="CargoCommandRunConfiguration" />
</history-entry>
<history-entry file="Test_solr_api__tests - 2019.05.02 at 15h 12m 33s.xml">
<configuration name="Test solr_api::tests" configurationId="CargoCommandRunConfiguration" />
</history-entry>
<history-entry file="Test_solr_api__tests - 2019.05.02 at 15h 13m 50s.xml">
<configuration name="Test solr_api::tests" configurationId="CargoCommandRunConfiguration" />
</history-entry>
<history-entry file="Test_solr_api__tests - 2019.05.02 at 15h 14m 39s.xml">
<configuration name="Test solr_api::tests" configurationId="CargoCommandRunConfiguration" />
</history-entry>
<history-entry file="Test_solr_api__tests - 2019.05.03 at 09h 23m 38s.xml">
<configuration name="Test solr_api::tests" configurationId="CargoCommandRunConfiguration" />
</history-entry>
<history-entry file="Test_solr_api__tests - 2019.05.03 at 09h 39m 37s.xml">
<configuration name="Test solr_api::tests" configurationId="CargoCommandRunConfiguration" />
</history-entry>
</component>
<component name="ToolWindowManager">
<frame x="1463" y="23" width="1733" height="1282" extended-state="0" />
<frame x="552" y="44" width="1733" height="1282" extended-state="0" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.24285714" visible="true" weight="0.26729745" />
<window_info id="Structure" order="1" sideWeight="0.75714284" side_tool="true" visible="true" weight="0.26729745" />
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.24310777" visible="true" weight="0.26729745" />
<window_info id="Structure" order="1" sideWeight="0.7568922" side_tool="true" visible="true" weight="0.26729745" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32941177" />
<window_info active="true" anchor="bottom" x="2387" y="116" width="972" height="1064" id="Run" order="2" sideWeight="0.49970433" type="WINDOWED" visible="true" weight="0.35210085" />
<window_info anchor="bottom" id="Find" order="1" visible="true" weight="0.32941177" />
<window_info anchor="bottom" x="2454" y="149" width="972" height="1064" id="Run" order="2" sideWeight="0.49970433" type="WINDOWED" visible="true" weight="0.35210085" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -320,20 +421,6 @@
</layout-to-restore>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/../Thruster/src/builtins/cookies.rs" />
<entry file="file://$USER_HOME$/.rustup/toolchains/beta-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/collections/hash/map.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="399">
<caret line="1251" column="15" selection-start-line="1251" selection-start-column="11" selection-end-line="1251" selection-end-column="15" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../Thruster/src/builtins/send.rs" />
<entry file="file://$PROJECT_DIR$/../Thruster/src/response.rs" />
<entry file="file://$PROJECT_DIR$/../Thruster/src/builtins/basic_hyper_context.rs" />
<entry file="file://$PROJECT_DIR$/../Thruster/examples/hyper_most_basic.rs" />
<entry file="file://$PROJECT_DIR$/../Thruster/src/app.rs" />
<entry file="file://$PROJECT_DIR$/../Thruster/src/testing/mod.rs" />
<entry file="file://$PROJECT_DIR$/../Thruster/examples/hello_world/context.rs" />
<entry file="file://$PROJECT_DIR$/../Thruster/src/builtins/query_params.rs" />
<entry file="file://$PROJECT_DIR$/../Thruster/src/builtins/basic_context.rs" />
@@ -379,10 +466,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/solr_api/select.rs" />
<entry file="file://$PROJECT_DIR$/src/solr_api/admin.rs" />
<entry file="file://$PROJECT_DIR$/src/solr_api/context.rs" />
<entry file="file://$PROJECT_DIR$/src/solr_api/query_params.rs" />
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/thruster-0.6.3/src/builtins/basic_context.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="91">
@@ -412,8 +495,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/solr_api/mod.rs" />
<entry file="file://$PROJECT_DIR$/src/solr_api/service.rs" />
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/thruster-0.7.1/src/lib.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="285">
@@ -544,19 +625,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/solr_api.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="769">
<caret line="127" selection-start-line="126" selection-end-line="127" />
<folding>
<element signature="e#719#1112#0" />
<element signature="e#1288#1826#0" />
<element signature="e#3882#3883#0" expanded="true" />
<element signature="e#3902#3903#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-0.7.9/src/system.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="307">
@@ -571,17 +639,121 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Cargo.toml">
<entry file="file://$PROJECT_DIR$/src/solr_api.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="57">
<caret line="8" selection-start-line="8" selection-end-line="8" />
<state relative-caret-position="-1318">
<caret line="24" column="1" lean-forward="true" selection-start-line="24" selection-start-column="1" selection-end-line="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/solr_api.bk/mod.rs">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/solr_api/context.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-6702" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/solr_api/service.rs">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/Cargo.toml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="36">
<caret line="8" column="16" selection-start-line="8" selection-start-column="16" selection-end-line="8" selection-end-column="16" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/solr_api/test.rs">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-0.7.19/src/server/http.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="585">
<caret line="314" column="11" selection-start-line="314" selection-start-column="11" selection-end-line="314" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-0.7.19/src/application.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="406">
<caret line="562" column="75" lean-forward="true" selection-start-line="562" selection-start-column="30" selection-end-line="562" selection-end-column="75" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-0.7.19/src/client/request.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="402">
<caret line="293" column="15" lean-forward="true" selection-start-line="293" selection-start-column="15" selection-end-line="293" selection-end-column="15" />
<folding>
<element signature="e#22650#22651#0" expanded="true" />
<element signature="e#22687#22688#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/url-1.7.2/src/lib.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="681">
<caret line="189" column="34" lean-forward="true" selection-start-line="189" selection-start-column="34" selection-end-line="189" selection-end-column="34" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-0.7.19/src/test.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="241">
<caret line="114" column="57" selection-start-line="114" selection-start-column="46" selection-end-line="114" selection-end-column="57" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/http-0.1.16/src/status.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="387">
<caret line="42" column="11" selection-start-line="42" selection-start-column="11" selection-end-line="42" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/solr_api/query_params.rs">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/solr_api/select.rs">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/main.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="676">
<caret line="69" column="35" selection-start-line="69" selection-start-column="35" selection-end-line="69" selection-end-column="35" />
<state relative-caret-position="300">
<caret line="20" selection-start-line="20" selection-end-line="20" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/solr_api/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="577">
<caret line="40" selection-start-line="40" selection-end-line="40" />
<folding>
<element signature="e#2490#2808#0" />
<element signature="e#3600#3745#0" />
<element signature="e#4720#4721#0" expanded="true" />
<element signature="e#4750#4751#0" expanded="true" />
<element signature="e#4109#4111#0" />
<element signature="e#5113#5114#0" expanded="true" />
<element signature="e#5147#5148#0" expanded="true" />
<element signature="e#5198#5199#0" expanded="true" />
<element signature="e#5257#5258#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/solr_api/admin.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="3840">
<caret line="340" column="35" selection-start-line="340" selection-start-column="35" selection-end-line="340" selection-end-column="35" />
<folding>
<element signature="e#46#592#0" />
<element signature="e#594#1142#0" />
<element signature="e#1144#1692#0" />
<element signature="e#1694#2242#0" />
</folding>
</state>
</provider>
</entry>

1
Cargo.lock generated
View File

@@ -1126,7 +1126,6 @@ version = "0.1.0"
dependencies = [
"actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

View File

@@ -6,8 +6,7 @@ edition = "2018"
[dependencies]
# Framework Web
futures = "0.1"
#env_logger = "0.5"
#futures = "0.1"
actix = "0.7"
actix-web = "0.7"

80
README.md Normal file
View File

@@ -0,0 +1,80 @@
# Mercator Service
REST-based HTTP service for Mercator.
## Mercator: Spatial Index
**Mercator** is a spatial *volumetric* index for the [Human Brain Project](http://www.humanbrainproject.eu). It is a component of the [Knowledge Graph](http://www.humanbrainproject.eu/en/explore-the-brain/search/) service, which provides the spatial anchoring for the metadata registered as well as processes the volumetric queries.
It is build on top of the Iron Sea database toolkit.
## Iron Sea: Database Toolkit
**Iron Sea** provides a set of database engine bricks, which can be combined and applied on arbitrary data structures.
Unlike a traditional database, it does not assume a specific physical structure for the tables nor the records, but relies on the developper to provide a set of extractor functions which are used by the specific indices provided.
This enables the index implementations to be agnostic from the underlying data structure, and re-used.
## Requirements
### Hardware
* **Processor:** 1GHz CPU
* **RAM:** Y MB per MB of indexed data
* **Available storage space:** X MB per MB of indexed data
### Software
* Rust: https://www.rust-lang.org
## Quick start
## Building from sources
To build this project, you will need to run the following:
```sh
cargo build --release
```
### Installation
To install the software on the system you can use:
```sh
cargo install --release
```
### Usage
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vehicula pretium
quam sit amet facilisis. Class aptent taciti sociosqu ad litora torquent per
conubia nostra, per inceptos himenaeos. Curabitur metus sapien, rhoncus vitae
eleifend nec, convallis vel nunc. Nulla metus mauris, porta eu porta eu,
vulputate et est. Suspendisse lacinia leo vel auctor aliquet. Maecenas non arcu
libero. Nulla ut eleifend dui. Cras bibendum pharetra facilisis. Proin mattis
libero non pharetra tristique. Nam massa nulla, ultrices pharetra quam a,
fermentum placerat dolor. Nullam mollis libero et neque lobortis, id dignissim
lectus dignissim. Maecenas ligula enim, congue in ornare vel, volutpat ut ante.
```sh
cargo run --release
```
## Documentation
For more information, please refer to the [documentation](https://epfl-dias.github.io/mercator_service/).
If you want to build the documentation and access it locally, you can use:
```sh
cargo doc --open
```
## Acknowledgements
This open source software code was developed in part or in whole in the
Human Brain Project, funded from the European Unions Horizon 2020
Framework Programme for Research and Innovation under the Specific Grant
Agreement No. 785907 (Human Brain Project SGA2).

View File

@@ -1,5 +1,5 @@
// WebService framework
#![cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))]
//#![cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))]
extern crate actix;
extern crate actix_web;
@@ -11,60 +11,13 @@ extern crate pretty_env_logger;
use std::sync::Arc;
use std::sync::RwLock;
mod solr_api {
mod solr_api;
use std::sync::Arc;
use std::sync::RwLock;
use actix::SystemRunner;
use actix_web::{middleware, server, App, HttpRequest, HttpResponse};
/// simple handle
fn index(req: &HttpRequest<AppState>) -> HttpResponse {
println!("{:?}", req);
{
// So that we release ASAP the exclusive lock.
*(req.state().shared.write().unwrap()) += 1;
}
HttpResponse::Ok().body(format!(
"Num of requests: {}",
req.state().shared.read().unwrap()
))
}
// Application shared state
struct AppState {
host: &'static str,
port: u16,
prefix: &'static str,
shared: Arc<RwLock<i32>>,
}
pub fn run(host: &'static str, port: u16, prefix: &'static str, state: Arc<RwLock<i32>>) -> () {
info!("Initializing server...");
let sys = actix::System::new("spatial-search");
server::new(move || {
App::with_state(AppState {
host,
port,
prefix,
shared: state.clone(),
}) // <- create app with shared state
// register simple handler, handle all methods
.resource("/", |r| r.f(index))
})
.bind(format!("{}:{}", host, port))
.unwrap()
.start();
info!("Started http server: {:?}:{:?}", host, port);
let _ = sys.run();
}
/*
fn into_bool(string: &str) -> bool {
string.eq_ignore_ascii_case("true") || string.eq_ignore_ascii_case("on")
}
*/
fn main() {
std::env::set_var("RUST_LOG", "info");

171
src/solr_api/mod.rs Normal file
View File

@@ -0,0 +1,171 @@
use std::sync::Arc;
use std::sync::RwLock;
use actix_web::http::{Method, StatusCode};
use actix_web::server::{HttpHandler, HttpHandlerTask};
use actix_web::{fs, pred, server, App, HttpRequest, HttpResponse, Result};
pub type SharedState = i32;
// Application shared state
struct AppState {
/*host: &'static str,
port: u16,
prefix: &'static str,*/
shared: Arc<RwLock<SharedState>>,
}
// simple handle
fn index(req: &HttpRequest<AppState>) -> HttpResponse {
println!("{:?}", req);
{
// So that we release ASAP the exclusive lock.
*(req.state().shared.write().unwrap()) += 1;
}
HttpResponse::BadRequest().body(format!(
"Num of requests: {}",
req.state().shared.read().unwrap()
))
}
/// 400 handler
fn page_400(_req: &HttpRequest<AppState>) -> Result<fs::NamedFile> {
Ok(fs::NamedFile::open("static/400.html")?.set_status_code(StatusCode::BAD_REQUEST))
}
/// 404 handler
fn page_404(_req: &HttpRequest) -> Result<fs::NamedFile> {
Ok(fs::NamedFile::open("static/404.html")?.set_status_code(StatusCode::NOT_FOUND))
}
fn get_app(
prefix: &'static str,
state: Arc<RwLock<SharedState>>,
) -> Vec<Box<HttpHandler<Task = Box<HttpHandlerTask>>>> {
vec![
App::with_state(AppState { shared: state })
.prefix(format!("{}", prefix))
// register simple handler, handle all methods
.resource("/", |r| r.f(index))
// default
.default_resource(|r| {
// 400 for GET request
r.f(page_400);
})
.boxed(),
App::new()
.default_resource(|r| {
// 404 for GET request
r.method(Method::GET).f(page_404);
// all requests that are not `GET`
r.route()
.filter(pred::Not(pred::Get()))
.f(|_req| HttpResponse::MethodNotAllowed());
})
.boxed(),
]
}
pub fn run(
host: &'static str,
port: u16,
prefix: &'static str,
state: Arc<RwLock<SharedState>>,
) -> () {
info!("Initializing server...");
let sys = actix::System::new("spatial-search");
server::new(move || get_app(prefix, state.clone()))
.bind(format!("{}:{}", host, port))
.unwrap()
.start();
info!("Started http server: {}:{}{}", host, port, prefix);
let _ = sys.run();
}
#[cfg(test)]
mod tests {
use super::*;
use actix_web::http;
use actix_web::test::{TestRequest, TestServer};
const PREFIX: &str = "spatial-search";
fn get_test_server() -> TestServer {
let state = Arc::new(RwLock::new(0));
TestServer::with_factory(move || get_app(PREFIX, state.clone()))
}
fn expect_200(path: &str) -> () {
let mut srv = get_test_server();
let req = srv.client(http::Method::GET, path).finish().unwrap();
let response = srv.execute(req.send()).unwrap();
assert_eq!(http::StatusCode::OK, response.status());
}
fn expect_400(path: &str) -> () {
let mut srv = get_test_server();
let req = srv.client(http::Method::GET, path).finish().unwrap();
let response = srv.execute(req.send()).unwrap();
assert_eq!(http::StatusCode::BAD_REQUEST, response.status());
}
fn expect_404(path: &str) -> () {
let mut srv = get_test_server();
let req = srv.client(http::Method::GET, path).finish().unwrap();
let response = srv.execute(req.send()).unwrap();
assert_eq!(http::StatusCode::NOT_FOUND, response.status());
}
#[test]
fn page_400() {
let response = TestRequest::with_state(AppState {
shared: Arc::new(RwLock::new(0)),
})
.run(&super::page_400)
.unwrap();
assert_eq!(response.status(), http::StatusCode::BAD_REQUEST);
}
#[test]
fn page_404() {
let response = TestRequest::default().run(&super::page_404).unwrap();
assert_eq!(response.status(), http::StatusCode::NOT_FOUND);
}
#[test]
fn default_no_path() {
expect_404("");
}
#[test]
fn default_slash() {
expect_404("/");
expect_404("//");
expect_404("/ /");
expect_404("/ //");
expect_404("// ");
}
#[test]
fn default_invalid_prefix() {
expect_404("/test");
expect_404(format!("{}test", PREFIX).as_str());
}
#[test]
fn default_prefix_no_slash() {
expect_400(PREFIX);
}
#[test]
fn default_prefix_final_slash() {
expect_400(format!("{}/", PREFIX).as_str());
}
}

8
static/400.html Normal file
View File

@@ -0,0 +1,8 @@
<html>
<head>
<title>400 - Bad Request</title>
</head>
<body>
<h1>400 - Bad Request</h1>
</body>
</html>

8
static/404.html Normal file
View File

@@ -0,0 +1,8 @@
<html>
<head>
<title>404 - Page not found</title>
</head>
<body>
<h1>404 - Page not found</h1>
</body>
</html>