Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
duniter-rs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jm
duniter-rs
Commits
aebe34a4
Commit
aebe34a4
authored
Feb 20, 2019
by
jm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] hyper web server
parent
c89d5e21
Pipeline
#4702
canceled with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
2 deletions
+83
-2
Cargo.lock
Cargo.lock
+45
-0
lib/modules/gva/Cargo.toml
lib/modules/gva/Cargo.toml
+1
-0
lib/modules/gva/lib.rs
lib/modules/gva/lib.rs
+37
-2
No files found.
Cargo.lock
View file @
aebe34a4
...
...
@@ -633,6 +633,7 @@ dependencies = [
"durs-message 0.1.0-a0.1",
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.12.19 (registry+https://github.com/rust-lang/crates.io-index)",
"juniper 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
...
...
@@ -1022,6 +1023,32 @@ dependencies = [
"quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "hyper"
version = "0.12.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"h2 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-executor 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-reactor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-tcp 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-timer 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "idna"
version = "0.1.5"
...
...
@@ -2327,6 +2354,11 @@ dependencies = [
"trust-dns-proto 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "try-lock"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "typenum"
version = "1.10.0"
...
...
@@ -2453,6 +2485,16 @@ name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "want"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"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)",
"try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "widestring"
version = "0.2.2"
...
...
@@ -2630,6 +2672,7 @@ dependencies = [
"checksum http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "02096a6d2c55e63f7fcb800690e4f889a25f6ec342e3adb4594e293b625215ab"
"checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83"
"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114"
"checksum hyper 0.12.19 (registry+https://github.com/rust-lang/crates.io-index)" = "f1ebec079129e43af5e234ef36ee3d7e6085687d145b7ea653b262d16c6b65f1"
"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
"checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d"
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
...
...
@@ -2771,6 +2814,7 @@ dependencies = [
"checksum trust-dns-proto 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0838272e89f1c693b4df38dc353412e389cf548ceed6f9fd1af5a8d6e0e7cf74"
"checksum trust-dns-proto 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e33f29df428f112ffeda24b328b814b61d6916be29aa89f19bc3f684ba5437b8"
"checksum trust-dns-resolver 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "de630f95a192f793436ffae5137e88253cc4142a97d9a8e73c8d804fa85ddf0a"
"checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382"
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
"checksum ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "71a9c5b1fe77426cf144cc30e49e955270f5086e31a6441dfa8b32efc09b9d77"
"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
...
...
@@ -2792,6 +2836,7 @@ dependencies = [
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "797464475f30ddb8830cc529aaaae648d581f99e2036a928877dfde027ddf6b3"
"checksum widestring 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7157704c2e12e3d2189c507b7482c52820a16dfa4465ba91add92f266667cadb"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
...
...
lib/modules/gva/Cargo.toml
View file @
aebe34a4
...
...
@@ -26,6 +26,7 @@ env_logger = "0.5"
actix
=
"0.7"
actix-web
=
"0.7"
futures
=
"0.1"
hyper
=
"0.12"
[features]
# Treat warnings as a build error.
...
...
lib/modules/gva/lib.rs
View file @
aebe34a4
...
...
@@ -48,9 +48,23 @@ use std::time::{Duration, SystemTime};
extern
crate
serde
;
extern
crate
serde_json
;
extern
crate
hyper
;
use
hyper
::{
Body
,
Request
,
Response
,
Server
};
use
hyper
::
rt
::
Future
;
use
hyper
::
service
::
service_fn_ok
;
/// Name of your module
pub
static
MODULE_NAME
:
&
'static
str
=
"gva"
;
static
PHRASE
:
&
str
=
"Hello world!
\n
"
;
fn
hello_world
(
_
req
:
Request
<
Body
>
)
->
Response
<
Body
>
{
Response
::
new
(
Body
::
from
(
PHRASE
))
}
#[derive(Debug,
Clone,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize)]
/// Gva Module Configuration
pub
struct
GvaConf
{
...
...
@@ -108,6 +122,22 @@ impl Default for GvaModule {
}
}
fn
start_web_server
()
{
println!
(
"Server start!!"
,);
let
addr
=
([
127
,
0
,
0
,
1
],
3000
)
.into
();
let
new_svc
=
||
{
service_fn_ok
(
hello_world
)
};
let
server
=
Server
::
bind
(
&
addr
)
.serve
(
new_svc
)
.map_err
(|
e
|
eprintln!
(
"server error: {}"
,
e
));
println!
(
"Starting server at {}..."
,
addr
);
hyper
::
rt
::
run
(
server
);
println!
(
"Server started"
,);
}
impl
DursModule
<
DuRsConf
,
DursMsg
>
for
GvaModule
{
type
ModuleConf
=
GvaConf
;
type
ModuleOpt
=
GvaOpt
;
...
...
@@ -131,6 +161,9 @@ impl DursModule<DuRsConf, DursMsg> for GvaModule {
module_conf
:
Self
::
ModuleConf
,
subcommand_args
:
Self
::
ModuleOpt
,
)
{
println!
(
"test print testtest"
);
let
mut
conf
=
soft_meta_datas
.conf
.clone
();
let
new_gva_conf
=
GvaConf
{
test_fake_conf_field
:
subcommand_args
.new_conf_field
.clone
(),
...
...
@@ -173,6 +206,8 @@ impl DursModule<DuRsConf, DursMsg> for GvaModule {
}
}
// Instanciate Gva module datas
let
datas
=
GvaModuleDatas
{
child_threads
:
Vec
::
new
(),
...
...
@@ -246,7 +281,7 @@ impl DursModule<DuRsConf, DursMsg> for GvaModule {
*/
loop
{
// Get messages
match
gva_receiver
.recv_timeout
(
Duration
::
from_millis
(
250
))
{
match
gva_receiver
.recv_timeout
(
Duration
::
from_millis
(
250
00
))
{
Ok
(
ref
message
)
=>
match
*
message
{
GvaMsg
::
DursMsg
(
ref
durs_message
)
=>
{
match
durs_message
.deref
()
{
...
...
@@ -315,7 +350,7 @@ impl DursModule<DuRsConf, DursMsg> for GvaModule {
}
// If you want your module's main thread to do things even when it doesn't receive any messages, this is the place where it can do them.
// ...
// start atix web server
start_web_server
();
//
}
// If we reach this point it means that the module has stopped correctly, so we return OK.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment