Foreman component

Steffen Kaiser skdovecot at
Wed Apr 20 05:35:38 UTC 2016

Hash: SHA1

On Tue, 19 Apr 2016, Aki Tuomi wrote:

Hi Aki,
> I am planning to add foreman component to dovecot core and I am hoping
> for some feedback:
> Foreman - generic per-user worker handling component
> It is responsible for managing worker pools per protocol, lifecycle
> management of workers and handing out instances to others, as in, unix
> socket connections.
> Each time a request is made to foreman for a worker, the worker is
> instantiated (if possible) and locked. Then connection is created to the
> socket of the worker, and the file descriptor is returned to requestor.

this is not like a multiplexor, that forwards the data between client and 
worker, but Forman will pass the new fd back to the client and may close 
the connection to it, right?


> When the requestor has completed the task, it's responsibility is to
> close the DATA channel and also ask foreman to unlock the worker.

If the client abends, Foreman would held the worker locked forever. 
Workers should notify their Foreman, that they are ready to take another 
task. Or, when a new client wants to make a connection to a worker, 
Foreman could probe unlocked workers first, then locked workers, if they 
are available. So the "locked" state is more a soft rather than a hard 

> Components can register new workers using lib-foreman's API. Each worker
> is registered with
> struct foreman_worker {
>    const char *protocol;
>    const char *path;
>    const char *version;
>    unsigned int max_instances;
>    unsigned int max_requests; /* how many requests one worker can handle */
>    unsigned int max_idletime_secs; /* how long worker can idle */
>    unsigned int max_processtime_secs; /* how long worker can process
> something */
>    unsigned int max_lifetime_secs; /* how long a worker can live
>                       this can be exceeded if the worker
>                       has work to do. */
> };
> /* minimum lifetime of worker: max_idletime_secs */
> /* absolute maximum lifetime of worker: max_lifetime_secs +
> max_processtime_secs */
> The unsigned ints are optional. If they are not defined, the workers are
> kept until foreman exceeds the total number of workers permitted across
> pools.
> Pools are per-worker-class pools, and are generated when a worker is
> registered.
> Version specifies the protocol version and is going to be "1000" now.
> Next version will always be 1001, 1002 etc.

> Any feedback or questions are welcome!
> Aki

- -- 
Steffen Kaiser
Version: GnuPG v1


More information about the dovecot mailing list