supervision
Aaron J. Seigo
aseigo at kde.org
Mon Aug 4 18:17:48 UTC 2014
Hi ..
As explained in the previous email, supervisors oversee processes. To make
this as easy and evident as possible, I decided to allow defining how the
supervisors in an application should be constructed with a declarative syntax
that is modeled after Qt's QML.
An example (from the git repo) is attached. Documentation is in
docs/supervision.md. It's not particularly complex, or at least I hope it
isn't :)
The funq compiler will turn the declarative syntax into a data structure that
is available at runtime which reflects the supervision processes. There are
still some details that I'm working out, but I am already fairly happy with
where it is now..
One point I'm still very undecided on, however, is supervisors that run user
functions: currently in the design supervisors are processes which are
entirely defined and managed by the funq compiler and runtime. This keeps is
simple. It could be possible to allow supervisors to also run a user defined
function as its "main"; process management would happen in addition to that
function running with the only caveat being that it could be possible for the
user defined function to enter a non-halting state which would prevent the
process management code from being run. A way around this would be to make
supervisors truly special processes internally rather than just regular funq
functions-in-a-process with the scheduler actively 'pre-empting' such
supervisors to do process management. This would make the internals a little
more complex, which is why I haven't designed that in, but it could be quite
useful to have. I keep going back and forth on whether to do it or not :)
--
Aaron J. Seigo
-------------- next part --------------
Supervisor {
id: cardTradingGame
Policy {
id: restarter
restart: yes
maxFails: 5
timeout: 5000
log: true
}
Policy {
id: quitOnExit
func: org.myproject.shutdown
log: true
}
onFailure: restarter
onCleanExit: quitOnExit
Supervisor {
id: networking
Process {
id: networkBroker
func: org.myproject.NetworkPool.pool(localhost, 8000)
poolSize: 5
onFailure: {
restart: all,
maxFails: 10,
timeout: 1000
}
}
}
Supervisor {
id: negotiations
onFailure: {
restart: no
}
Process {
id: sale
func: org.myroject.negotiate.sell
createOnDemand: true
poolSize: 20
}
Process {
id: auction
func: org.myroject.negotiate.auction
createOnDemand: true
}
}
Supervisor {
id: pools
func: std.resourcePool
onFailure: restarter
Process {
id: resource
createOnDemand: true
}
}
Process {
id: userInterface
func: org.myproject.GUI
priority: critical // ensure it gets more cycles
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://kde.org/pipermail/funq-devel/attachments/20140804/0dd0b980/attachment.sig>
More information about the Funq-devel
mailing list