Using passive regions.
Improve connector options mainly for standalone connector. Updated "simple" example to return a timestamp.
This commit is contained in:
@@ -20,7 +20,12 @@ feature {NONE} -- Initialization
|
|||||||
initialize
|
initialize
|
||||||
-- Initialize current service.
|
-- Initialize current service.
|
||||||
do
|
do
|
||||||
set_service_option ("port", 9090)
|
-- Specific to `standalone' connector (the EiffelWeb server).
|
||||||
|
-- See `{WSF_STANDALONE_SERVICE_LAUNCHER}.initialize'
|
||||||
|
set_service_option ("port", 9090)
|
||||||
|
set_service_option ("max_concurrent_connections", 10)
|
||||||
|
set_service_option ("keep_alive_timeout", 1)
|
||||||
|
set_service_option ("verbose", True)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,13 @@ feature -- Basic operations
|
|||||||
execute
|
execute
|
||||||
local
|
local
|
||||||
s: STRING
|
s: STRING
|
||||||
do
|
dt: HTTP_DATE
|
||||||
-- To send a response we need to setup, the status code and
|
do
|
||||||
-- the response headers.
|
-- To send a response we need to setup, the status code and
|
||||||
s := "Hello World!"
|
-- the response headers.
|
||||||
|
s := "Hello World!"
|
||||||
|
create dt.make_now_utc
|
||||||
|
s.append (" (UTC time is " + dt.rfc850_string + ").")
|
||||||
response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/html"], ["Content-Length", s.count.out]>>)
|
response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/html"], ["Content-Length", s.count.out]>>)
|
||||||
response.set_status_code ({HTTP_STATUS_CODE}.ok)
|
response.set_status_code ({HTTP_STATUS_CODE}.ok)
|
||||||
response.header.put_content_type_text_html
|
response.header.put_content_type_text_html
|
||||||
|
|||||||
@@ -1,35 +1,28 @@
|
|||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="simple" uuid="C28C4F53-9963-46C0-A080-8F13E94E7486" library_target="simple">
|
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="simple" uuid="C28C4F53-9963-46C0-A080-8F13E94E7486" library_target="simple">
|
||||||
<target name="common" abstract="true">
|
<target name="common" abstract="true">
|
||||||
<file_rule>
|
<file_rule>
|
||||||
<exclude>/EIFGENs$</exclude>
|
|
||||||
<exclude>/CVS$</exclude>
|
|
||||||
<exclude>/.svn$</exclude>
|
<exclude>/.svn$</exclude>
|
||||||
|
<exclude>/CVS$</exclude>
|
||||||
|
<exclude>/EIFGENs$</exclude>
|
||||||
</file_rule>
|
</file_rule>
|
||||||
<option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
|
<option warning="true" full_class_checking="false" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="transitional" syntax="transitional">
|
||||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||||
</option>
|
</option>
|
||||||
|
<setting name="console_application" value="true"/>
|
||||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
<library name="http" location="..\..\library\network\protocol\http\http-safe.ecf"/>
|
<library name="http" location="..\..\library\network\protocol\http\http-safe.ecf"/>
|
||||||
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf"/>
|
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf"/>
|
||||||
</target>
|
</target>
|
||||||
<target name="simple_standalone" extends="common">
|
<target name="simple_standalone" extends="common">
|
||||||
<root class="APPLICATION" feature="make_and_launch"/>
|
<root class="APPLICATION" feature="make_and_launch"/>
|
||||||
<option warning="true" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
|
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
||||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||||
</option>
|
</option>
|
||||||
<setting name="concurrency" value="thread"/>
|
<setting name="concurrency" value="scoop"/>
|
||||||
<library name="default_standalone" location="..\..\library\server\wsf\default\standalone-safe.ecf"/>
|
<library name="default_standalone" location="..\..\library\server\wsf\default\standalone-safe.ecf"/>
|
||||||
<cluster name="simple" location=".\" recursive="true"/>
|
<cluster name="simple" location=".\" recursive="true"/>
|
||||||
</target>
|
</target>
|
||||||
<target name="simple_nino" extends="common">
|
|
||||||
<root class="APPLICATION" feature="make_and_launch"/>
|
|
||||||
<option warning="true" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
|
|
||||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
|
||||||
</option>
|
|
||||||
<library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf"/>
|
|
||||||
<cluster name="simple" location=".\" recursive="true"/>
|
|
||||||
</target>
|
|
||||||
<target name="simple_cgi" extends="common">
|
<target name="simple_cgi" extends="common">
|
||||||
<root class="APPLICATION" feature="make_and_launch"/>
|
<root class="APPLICATION" feature="make_and_launch"/>
|
||||||
<option warning="true" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
|
<option warning="true" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ feature {NONE} -- Initialization
|
|||||||
local
|
local
|
||||||
n: INTEGER
|
n: INTEGER
|
||||||
p: like pool
|
p: like pool
|
||||||
do
|
do
|
||||||
n := max_concurrent_connections (server)
|
n := max_concurrent_connections (server).max (1) -- At least one processor!
|
||||||
create p.make (n)
|
create p.make (n)
|
||||||
initialize_pool (p, n)
|
initialize_pool (p, n)
|
||||||
pool := p
|
pool := p
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ feature {NONE} -- Initialization
|
|||||||
local
|
local
|
||||||
n: INTEGER
|
n: INTEGER
|
||||||
do
|
do
|
||||||
n := max_concurrent_connections (server)
|
n := max_concurrent_connections (server).max (1) -- At least one thread!
|
||||||
create pool.make (n.to_natural_32)
|
create pool.make (n.to_natural_32)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ feature -- Access
|
|||||||
max_concurrent_connections: INTEGER assign set_max_concurrent_connections
|
max_concurrent_connections: INTEGER assign set_max_concurrent_connections
|
||||||
socket_accept_timeout: INTEGER assign set_socket_accept_timeout
|
socket_accept_timeout: INTEGER assign set_socket_accept_timeout
|
||||||
socket_connect_timeout: INTEGER assign set_socket_connect_timeout
|
socket_connect_timeout: INTEGER assign set_socket_connect_timeout
|
||||||
|
|
||||||
force_single_threaded: BOOLEAN assign set_force_single_threaded
|
force_single_threaded: BOOLEAN assign set_force_single_threaded
|
||||||
do
|
do
|
||||||
Result := (max_concurrent_connections = 0)
|
Result := max_concurrent_connections = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
is_verbose: BOOLEAN assign set_is_verbose
|
is_verbose: BOOLEAN assign set_is_verbose
|
||||||
@@ -126,6 +127,10 @@ feature -- Element change
|
|||||||
end
|
end
|
||||||
|
|
||||||
set_force_single_threaded (v: like force_single_threaded)
|
set_force_single_threaded (v: like force_single_threaded)
|
||||||
|
-- Force server to handle incoming request in a single thread.
|
||||||
|
-- i.e set max_concurrent_connections to 0!
|
||||||
|
obsolete
|
||||||
|
"Use set_max_concurrent_connections (0) [June/2016]"
|
||||||
do
|
do
|
||||||
if v then
|
if v then
|
||||||
set_max_concurrent_connections (0)
|
set_max_concurrent_connections (0)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ feature {NONE} -- Initialization
|
|||||||
make
|
make
|
||||||
do
|
do
|
||||||
reset
|
reset
|
||||||
|
persistent_connection_timeout := 5 -- seconds
|
||||||
end
|
end
|
||||||
|
|
||||||
reset
|
reset
|
||||||
@@ -114,7 +115,7 @@ feature -- Settings
|
|||||||
Result := {HTTPD_SERVER}.is_persistent_connection_supported
|
Result := {HTTPD_SERVER}.is_persistent_connection_supported
|
||||||
end
|
end
|
||||||
|
|
||||||
persistent_connection_timeout: INTEGER = 5 -- seconds
|
persistent_connection_timeout: INTEGER -- seconds
|
||||||
-- Number of seconds for persistent connection timeout.
|
-- Number of seconds for persistent connection timeout.
|
||||||
-- Default: 5 sec.
|
-- Default: 5 sec.
|
||||||
|
|
||||||
@@ -210,17 +211,8 @@ feature -- Execution
|
|||||||
|
|
||||||
--| TODO: add configuration options for socket timeout.
|
--| TODO: add configuration options for socket timeout.
|
||||||
--| set by default 5 seconds.
|
--| set by default 5 seconds.
|
||||||
-- l_socket.set_timeout (persistent_connection_timeout) -- 5 seconds!
|
l_socket.set_timeout (persistent_connection_timeout) -- 5 seconds!
|
||||||
l_socket.set_timeout (1) -- 1 second!
|
l_is_ready := l_socket.ready_for_reading
|
||||||
from
|
|
||||||
i := persistent_connection_timeout -- * 1 sec
|
|
||||||
until
|
|
||||||
l_is_ready or i <= 0 or has_error
|
|
||||||
loop
|
|
||||||
l_is_ready := l_socket.ready_for_reading
|
|
||||||
check not l_socket.is_closed end
|
|
||||||
i := i - 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if l_is_ready then
|
if l_is_ready then
|
||||||
create l_remote_info
|
create l_remote_info
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ feature {NONE} -- Initialization
|
|||||||
build_controller
|
build_controller
|
||||||
-- Build `controller'.
|
-- Build `controller'.
|
||||||
do
|
do
|
||||||
create controller
|
create <NONE> controller
|
||||||
end
|
end
|
||||||
|
|
||||||
initialize
|
initialize
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
note
|
note
|
||||||
description: "Implementation of WGI request handler factory for WGI_STANDALOE_CONNECTOR."
|
description: "Implementation of WGI request handler factory for WGI_STANDALONE_CONNECTOR."
|
||||||
date: "$Date$"
|
date: "$Date$"
|
||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ feature -- Access
|
|||||||
|
|
||||||
feature -- Element change
|
feature -- Element change
|
||||||
|
|
||||||
set_connector (conn: like connector)
|
update_with (conn: like connector)
|
||||||
-- Set `connector' with `conn'.
|
-- Set `connector' with `conn'.
|
||||||
do
|
do
|
||||||
connector := conn
|
connector := conn
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ feature {NONE} -- Initialization
|
|||||||
create on_launched_actions
|
create on_launched_actions
|
||||||
|
|
||||||
-- Server
|
-- Server
|
||||||
create fac
|
create <NONE> fac
|
||||||
create server.make (fac)
|
create server.make (fac)
|
||||||
create observer
|
create <NONE> observer
|
||||||
configuration := server_configuration (server)
|
configuration := server_configuration (server)
|
||||||
controller := server_controller (server)
|
controller := server_controller (server)
|
||||||
set_factory_connector (Current, fac)
|
set_factory_connector (Current, fac)
|
||||||
@@ -53,7 +53,7 @@ feature {NONE} -- Separate helper
|
|||||||
|
|
||||||
set_factory_connector (conn: detachable separate WGI_STANDALONE_CONNECTOR [G]; fac: separate WGI_HTTPD_REQUEST_HANDLER_FACTORY [G])
|
set_factory_connector (conn: detachable separate WGI_STANDALONE_CONNECTOR [G]; fac: separate WGI_HTTPD_REQUEST_HANDLER_FACTORY [G])
|
||||||
do
|
do
|
||||||
fac.set_connector (conn)
|
fac.update_with (conn)
|
||||||
end
|
end
|
||||||
|
|
||||||
server_configuration (a_server: like server): like configuration
|
server_configuration (a_server: like server): like configuration
|
||||||
|
|||||||
@@ -39,33 +39,24 @@ feature {NONE} -- Initialization
|
|||||||
create on_stopped_actions
|
create on_stopped_actions
|
||||||
|
|
||||||
port_number := 80 --| Default, but quite often, this port is already used ...
|
port_number := 80 --| Default, but quite often, this port is already used ...
|
||||||
|
keep_alive_timeout := 5_000 -- 5 seconds.
|
||||||
base_url := ""
|
base_url := ""
|
||||||
|
|
||||||
if attached options as opts then
|
if attached options as opts then
|
||||||
if attached {READABLE_STRING_GENERAL} opts.option ("server_name") as l_server_name then
|
if attached {READABLE_STRING_GENERAL} opts.option ("server_name") as l_server_name then
|
||||||
server_name := l_server_name.to_string_8
|
server_name := l_server_name.to_string_8
|
||||||
end
|
end
|
||||||
if attached {INTEGER} opts.option ("port") as l_port then
|
|
||||||
port_number := l_port
|
|
||||||
elseif
|
|
||||||
attached {READABLE_STRING_GENERAL} opts.option ("port") as l_port_str and then
|
|
||||||
l_port_str.is_integer
|
|
||||||
then
|
|
||||||
port_number := l_port_str.as_string_8.to_integer
|
|
||||||
end
|
|
||||||
if attached {READABLE_STRING_GENERAL} opts.option ("base") as l_base_str then
|
if attached {READABLE_STRING_GENERAL} opts.option ("base") as l_base_str then
|
||||||
base_url := l_base_str.as_string_8
|
base_url := l_base_str.as_string_8
|
||||||
end
|
end
|
||||||
if attached {BOOLEAN} opts.option ("force_single_threaded") as l_single_threaded then
|
verbose := opts.option_boolean_value ("verbose", verbose)
|
||||||
single_threaded := l_single_threaded
|
port_number := opts.option_integer_value ("port", port_number)
|
||||||
elseif attached {READABLE_STRING_GENERAL} opts.option ("force_single_threaded") as l_single_threaded_str then
|
|
||||||
single_threaded := l_single_threaded_str.as_lower.same_string ("true")
|
if opts.option_boolean_value ("force_single_threaded", single_threaded) then
|
||||||
end
|
force_single_threaded
|
||||||
if attached {BOOLEAN} opts.option ("verbose") as l_verbose then
|
|
||||||
verbose := l_verbose
|
|
||||||
elseif attached {READABLE_STRING_GENERAL} opts.option ("verbose") as l_verbose_str then
|
|
||||||
verbose := l_verbose_str.as_lower.same_string ("true")
|
|
||||||
end
|
end
|
||||||
|
max_concurrent_connections := opts.option_integer_value ("max_concurrent_connections", max_concurrent_connections)
|
||||||
|
keep_alive_timeout := opts.option_integer_value ("keep_alive_timeout", keep_alive_timeout)
|
||||||
end
|
end
|
||||||
|
|
||||||
create conn.make
|
create conn.make
|
||||||
@@ -76,18 +67,24 @@ feature {NONE} -- Initialization
|
|||||||
update_configuration (conn.configuration)
|
update_configuration (conn.configuration)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
force_single_threaded
|
||||||
|
-- Set `single_threaded' to True.
|
||||||
|
do
|
||||||
|
max_concurrent_connections := 1
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Execution
|
feature -- Execution
|
||||||
|
|
||||||
update_configuration (cfg: like connector.configuration)
|
update_configuration (cfg: like connector.configuration)
|
||||||
do
|
do
|
||||||
if single_threaded then
|
|
||||||
cfg.set_force_single_threaded (True)
|
|
||||||
end
|
|
||||||
cfg.set_is_verbose (verbose)
|
cfg.set_is_verbose (verbose)
|
||||||
if attached server_name as l_server_name then
|
if attached server_name as l_server_name then
|
||||||
cfg.set_http_server_name (l_server_name)
|
cfg.set_http_server_name (l_server_name)
|
||||||
end
|
end
|
||||||
cfg.http_server_port := port_number
|
cfg.http_server_port := port_number
|
||||||
|
cfg.set_max_concurrent_connections (max_concurrent_connections)
|
||||||
|
cfg.set_keep_alive_timeout (keep_alive_timeout)
|
||||||
|
-- conn.update_configuration (cfg)
|
||||||
end
|
end
|
||||||
|
|
||||||
launch
|
launch
|
||||||
@@ -98,7 +95,7 @@ feature -- Execution
|
|||||||
do
|
do
|
||||||
conn := connector
|
conn := connector
|
||||||
conn.set_base (base_url)
|
conn.set_base (base_url)
|
||||||
debug ("nino")
|
debug ("ew_standalone")
|
||||||
if verbose then
|
if verbose then
|
||||||
io.error.put_string ("Launching standalone web server on port " + port_number.out)
|
io.error.put_string ("Launching standalone web server on port " + port_number.out)
|
||||||
if attached server_name as l_name then
|
if attached server_name as l_name then
|
||||||
@@ -136,6 +133,13 @@ feature {NONE} -- Implementation
|
|||||||
verbose: BOOLEAN
|
verbose: BOOLEAN
|
||||||
|
|
||||||
single_threaded: BOOLEAN
|
single_threaded: BOOLEAN
|
||||||
|
do
|
||||||
|
Result := max_concurrent_connections = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
max_concurrent_connections: INTEGER
|
||||||
|
|
||||||
|
keep_alive_timeout: INTEGER
|
||||||
|
|
||||||
feature -- Status report
|
feature -- Status report
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,42 @@ feature -- Access
|
|||||||
Result := options.item (a_name)
|
Result := options.item (a_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Helpers
|
||||||
|
|
||||||
|
option_integer_value (a_opt_name: READABLE_STRING_GENERAL; a_default: INTEGER): INTEGER
|
||||||
|
-- INTEGER value associated to option name `a_opt_name', other return `a_default'.
|
||||||
|
local
|
||||||
|
s: READABLE_STRING_GENERAL
|
||||||
|
do
|
||||||
|
Result := a_default
|
||||||
|
if attached option (a_opt_name) as opt then
|
||||||
|
if attached {INTEGER} opt as i then
|
||||||
|
Result := i
|
||||||
|
else
|
||||||
|
s := opt.out
|
||||||
|
if s.is_integer then
|
||||||
|
Result := s.to_integer
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
option_boolean_value (a_opt_name: READABLE_STRING_GENERAL; a_default: BOOLEAN): BOOLEAN
|
||||||
|
-- BOOLEAN value associated to option name `a_opt_name', other return `a_default'.
|
||||||
|
local
|
||||||
|
s: READABLE_STRING_GENERAL
|
||||||
|
do
|
||||||
|
Result := a_default
|
||||||
|
if attached option (a_opt_name) as opt then
|
||||||
|
if attached {BOOLEAN} opt as b then
|
||||||
|
Result := b
|
||||||
|
else
|
||||||
|
s := opt.out
|
||||||
|
Result := s.is_case_insensitive_equal ("true")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
new_cursor: TABLE_ITERATION_CURSOR [detachable ANY, READABLE_STRING_GENERAL]
|
new_cursor: TABLE_ITERATION_CURSOR [detachable ANY, READABLE_STRING_GENERAL]
|
||||||
|
|||||||
Reference in New Issue
Block a user