HttpServer
instances, and hold the libevent base handlernitcorn :: HttpFactory :: config=
Configuration of this servernitcorn :: HttpFactory :: defaultinit
nitcorn $ HttpFactory :: SELF
Type of this instance, automatically specialized in every classnitcorn :: pthreads $ HttpFactory :: and_libevent
Instantiate a server and libventnitcorn :: signal_handler $ HttpFactory :: callback
Callback on an eventnitcorn :: signal_handler $ HttpFactory :: run
Execute the main listening loop to accept connectionsnitcorn $ HttpFactory :: spawn_connection
Create a newConnection
object for buffer_event
libevent :: ConnectionFactory :: accept_connection
Accept a connection onlistener
libevent :: ConnectionFactory :: bind_tcp
Listen on the TCP socket ataddress
:port
for new connections
libevent :: ConnectionFactory :: bind_unix
Listen on a UNIX domain socket for new connectionscore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitcorn :: HttpFactory :: config=
Configuration of this serverlibevent :: EventCallback :: defaultinit
core :: Object :: defaultinit
nitcorn :: HttpFactory :: defaultinit
libevent :: ConnectionFactory :: event_base
TheNativeEventBase
for the dispatch loop of this factory
libevent :: ConnectionFactory :: event_base=
TheNativeEventBase
for the dispatch loop of this factory
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).libevent :: ConnectionFactory :: spawn_connection
Create a newConnection
object for buffer_event
# Factory to create `HttpServer` instances, and hold the libevent base handler
class HttpFactory
super ConnectionFactory
# Configuration of this server
#
# It should be populated after this object has instanciated
var config = new ServerConfig.with_factory(self)
# Instantiate a server and libvent
#
# You can use this to create the first `HttpFactory`, which is the most common.
init and_libevent do init(new NativeEventBase)
redef fun spawn_connection(buf_ev, address) do return new HttpServer(buf_ev, self, address)
# Execute the main listening loop to accept connections
#
# After the loop ends, the underlying resources are freed.
#
# When the environment variable `NIT_TESTING` is set to `true`,
# the loop is not executed but the resources are still freed.
fun run
do
if "NIT_TESTING".environ != "true" then
event_base.dispatch
end
event_base.free
end
end
lib/nitcorn/reactor.nit:123,1--153,3
redef class HttpFactory
super EventCallback
private var signal_handlers: Array[NativeEvSignal] = [
new NativeEvSignal(event_base, 2, self), # SIGINT
new NativeEvSignal(event_base, 15, self) # SIGTERM
] is lazy
redef fun run
do
for handler in signal_handlers do handler.add
super
end
redef fun callback(events)
do
event_base.loopexit
for handler in signal_handlers do handler.del
end
end
lib/nitcorn/signal_handler.nit:20,1--39,3
redef class HttpFactory
redef init and_libevent
do
use_pthreads
super
end
end
lib/nitcorn/pthreads.nit:21,1--27,3