# Module Netplex_types

    module Netplex_types: sig .. end

Types for `Netplex`

    type encap = Netplex_encap.encap

    type param_value = [ `Bool of bool | `Float of float | `Int of int | `String of string ]

    type param_value_or_any = [ `Any of exn
           | `Bool of bool
           | `Encap of encap
           | `Float of float
           | `Int of int
           | `String of string ]

    type level = [ `Alert | `Crit | `Debug | `Emerg | `Err | `Info | `Notice | `Warning ]

Log levels, modeled after syslog

    class type logger = object .. end

A logger receives log messages

    type parallelization_type = [ `Controller_attached | `Multi_processing | `Multi_threading ]

Type of parallelization:

- ``Multi_processing` on a single host
- ``Multi_threading` on a single host
- ``Controller_attached` means that the service runs within the controller. This is (for now) only allowed for controller-internal services.

    type thread_sys_id = [ `Process of int | `Thread of int ]

A system-specific identifier of the thread/process

    type socket_state = [ `Disabled | `Down | `Enabled | `Restarting of bool ]

The state of a socket:

- ``Enabled`: The controller allows containers to accept connections. Note that this does not necessarily means that there such containers.
- ``Disabled`: It is not allowed to accept new connections. The socket is kept open, however.
- ``Restarting b`: The containers are being restarted. The boolean argument says whether the socket will be enabled after that.
- ``Down`: The socket is down/closed

    type container_id = < socket_service_name : string >

Such objects identify containers. As additional info, the method `socket_service_name` returns the name of the socket service the container implements

    type container_state = [ `Accepting of int * float | `Busy | `Shutting_down | `Starting of float ]

The container state for workload management:

- ``Accepting(n,t)`: The container is accepting further connections. It currently processes `n` connections. The last connection was accepted at time `t` (seconds since the epoch).
- ``Busy`: The container does not accept connections
- ``Starting t`: The container was started at time `t` and is not yet ready.
- ``Shutting_down`: The container is being shutted down.

    type capacity = [ `Low_quality of int * bool | `Normal_quality of int * bool | `Unavailable ]

How many connections a container can accept in addition to the existing connections:

- ``Normal_quality(n,greedy)`: It can accept n connections with normal service quality, `n > 0`
- ``Low_quality(n,greedy)`: It can accept n connections with low service quality (e.g. because it is already quite loaded), `n > 0`
- ``Unavailable`: No capacity free

The `greedy` flag sets whether greedy accepts are allowed.

    type extended_address = [ `Container of
               string * string * string * [ `Any | `Process of int | `Thread of int ]
           | `Socket of Unix.sockaddr
           | `Socket_file of string
           | `W32_pipe of string
           | `W32_pipe_file of string ]

Possible addresses:

- ``Socket s`: The socket at this socket address
- ``Socket_file f`: The file `f` contains the (anonymous) port number of a socket bound to `127.0.0.1` (This is meant as substitute for Unix Domain sockets on Win32.)
- ``W32_pipe name`: The Win32 pipe with this `name` which must be of the form "\\.\pipe\<pname>"
- ``W32_pipe_file f`: The file `f` contains the (random) name of a Win32 pipe
- ``Container(socket_dir,service_name,proto_name,thread_id)`: The special endpoint of the container for `service_name` that is running as `thread_id`. It is system-dependent what this endpoint "is" in reality, usually a socket or named pipe. If any container of a service is meant, the value ``Any` is substituted as a placeholder for a not yet known `thread_id`.

    class type controller = object .. end

The controller is the object in the Netplex master process/thread that manages the containers, logging, and service definitions

    class type controller_config = object .. end

    class type socket_service = object .. end

    class type socket_service_config = object .. end

    class type protocol = object .. end

    class type socket_controller = object .. end

    class type ctrl_message_receiver = object .. end

    class type processor_hooks = object .. end

Processor hooks can be used to modify the behavior of a processor.

    class type processor = object .. end

The processor is the object that is notified when a new TCP connection is accepted.

    class type container = object .. end

Containers encapsulate the control flow of the service components.

    class type workload_manager = object .. end

See `Netplex_workload` for definitions of workload managers

    class type plugin = object .. end

Plugins are extensions of the Netplex system that run in the controller and can be invoked from containers

    class type par_thread = object .. end

    class type parallelizer = object .. end

    type config_tree = [ `Parameter of string * param_value
           | `Section of string * config_tree list ]

    type address = <  >

    class type config_file = object .. end

    class type processor_factory = object .. end

    class type workload_manager_factory = object .. end

    class type logger_factory = object .. end

    class type netplex_config = object .. end