Plasma GitLab Archive
Projects Blog Knowledge

Module Hydro_proxy


module Hydro_proxy: sig .. end
Base proxy functionality


Proxies

Proxies represent remote objects locally. A proxy is bound to remote objects, and forwards any RPC calls to these. The class type proxy_t accesses the core of the proxy functionality, which is also implemented as class proxy (below). The generator hydrogen creates more specialized proxies that can be much easier used. However, these proxies always extend the base class defined here.

Logically, a proxy is bound to one object only. However, it is possible to configure proxies so they think this object is available on several servers simultaneously (multiplicity parameter). There are two ways of taking advantage of this:

  • Failover behavior: Normally, always the same server is used. In case of a problem, it is failed over to the next server in the list (multiplicity=`Failover).
  • Concurrent behavior: All given servers are used at the same time by maintaining connections to all servers. If servers fail, they are (temporarily) not used for new calls (multiplicity=`Concurrent).
The connection management is fully automatic. The user needs not to indicate when to start a new connection, and for how long to use it. In case of failing servers it is possible, however, that individual RPC calls fail because of this. It is not tried to hide this fact. The user is free to repeat the call if it is semantically allowed.

To be exact, proxies do not keep the connections. This is the task of the pools. It is supported that a proxy shares connections to servers with other proxies, but proxy-private connections are also possible.

It is possible to tell the pools that certain hosts or certain services are currently unavailable - before proxies try to use them and run into problems. This is called temporary deactivation. Use the deactivate_host and deactivate_port methods to control this.

Types


type extended_proxy_addr = < facet : string option; id : Hydro_types.identity;
mode : Hydro_types.proxy_mode;
parameters : extended_proxy_parameters; secure : bool >
A proxy address where the parameters can also specify connectors directly
type extended_proxy_parameters = [ `Adapter of string
| `Connectors of
(Hydro_connector.client_connector * Hydro_types.client_params) list
| `Endpoints of Hydro_types.endpoint array
| `Well_known ]
type multiplicity = [ `Concurrent of int | `Failover ] 
See below
type shared_or_private = [ `Private of <  > | `Shared ] 
Internally used
type domain_resolver = Unixqueue.unix_event_system ->
string -> (Unix.inet_addr option -> unit) -> unit
A domain resolver is a function r called as r esys name reply. As name the domain name to resolve is passed. The resolver must finally call reply with either the resolved address or with None, indicating an error in the latter case. The event system esys can be used to carry out the resolution process in an asynchronous way, but this is optional.

Only 1:1 resolution is supported, 1:n resolution not.

class type proxy_conf_t = object .. end
Configures proxies
class type proxy_env_t = object .. end
The environment of proxies, usually shared by all proxies in the program
class type proxy_resolver_t = object .. end
class type proxy_t = object .. end
This is the base class type of every proxy.
class type pool_t = object .. end
A pool keeps connections from clients to servers
class type managed_client_t = object .. end
This is an internally used object that encapsulates clients

Implementation


val proxy_conf : ?shared_connections:bool ->
?multiplicity:multiplicity ->
?max_reconnections:int ->
?deactivation_period:float ->
?resolution_period:float ->
?context:(string * string) list -> unit -> proxy_conf_t
Create a fresh proxy configuration. Unspecified parameters are set to an implementation-defined default value.
val modify_proxy_conf : ?shared_connections:bool ->
?multiplicity:multiplicity ->
?max_reconnections:int ->
?deactivation_period:float ->
?resolution_period:float ->
?context:(string * string) list ->
proxy_conf_t -> proxy_conf_t
Create a proxy configuration that modifies the values found in the input configuration.
val proxy_resolver : ?domain_resolver:domain_resolver ->
Hydro_types.client_params -> proxy_resolver_t
The default resolver looks for available endpoints and returns them in the order they occur in the address. If possible, DNS lookups are done.

The passed client params serve as the base params. Depending on the endpoint, the params are modified:

  • If the endpoint specifies a timeout, the trans_timeout of the client is set to the minimum of the endpoint timeout and the found trans_timeout
  • If the endpoint specifies protocol and encoding numbers, these override the found numbers.
This resolver does not support indirect proxies.
val shuffle : Random.State.t ->
proxy_resolver_t -> proxy_resolver_t
shuffle rnd (proxy_resolver params): shuffles the endpoints so that they are in random order
val proxy : env:proxy_env_t ->
addr:extended_proxy_addr -> unit -> proxy_t
Create a proxy for this environment and this proxy address
val pool : unit -> pool_t
Default implementation of a pool.

Delegations


class proxy_delegation : proxy_t -> proxy_t
class proxy_env_delegation : proxy_env_t -> proxy_env_t
class proxy_resolver_delegation : proxy_resolver_t -> proxy_resolver_t
class pool_delegation : pool_t -> pool_t
This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml